Skip to content

Commit

Permalink
Split capture and render
Browse files Browse the repository at this point in the history
  • Loading branch information
DDRBoxman committed Oct 12, 2023
1 parent fc36e89 commit 18b4130
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/macos-xcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
run: |
xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO archive -archivePath archive.xcarchive -scheme Cappy3ds
xcodebuild -archivePath ./archive.xcarchive -exportArchive -exportPath ./ -exportOptionsPlist ./exportOptionsAdHoc.plist
dylibBundler -b -cd -d ./Cappy3ds.app/Contents/Frameworks -p @executable_path/../Frameworks/ -x ./Cappy3ds.app/Contents/Frameworks/libcappy3ds.dylib
install_name_tool -change /Users/runner/work/Cappy3ds/Cappy3ds/target/debug/deps/libcappy3ds.dylib @executable_path/../Frameworks/libcappy3ds.dylib ./Cappy3ds.app/Contents/MacOS/Cappy3ds
dylibBundler -b -cd -d ./Cappy3ds.app/Contents/Frameworks -p @executable_path/../Frameworks/ -x ./Cappy3ds.app/Contents/Frameworks/libcappy3ds_render.dylib
install_name_tool -change /Users/runner/work/Cappy3ds/Cappy3ds/target/debug/deps/libcappy3ds_render.dylib @executable_path/../Frameworks/libcappy3ds_render.dylib ./Cappy3ds.app/Contents/MacOS/Cappy3ds
zip -r -X ../result.zip Cappy3ds.app
- uses: actions/upload-artifact@v3
Expand Down
15 changes: 0 additions & 15 deletions Cappy3ds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,16 @@ name = "cappy3ds"
version = "0.1.0"
edition = "2021"

#build = "build.rs"

#[build-dependencies]
#cbindgen = "0.1.29"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
hex = "0.4.3"
rusb = "0.9"
rust-embed = "8.0.0"
bytes = "1.5.0"
nom = "7.1.3"
memchr = "2.6.3"
image = "0.24.7"
env_logger = "0.10"
log = "0.4"
wgpu = "0.17"
raw-window-handle = "0.5.2"
futures = "0.3.28"
libusb1-sys = "0.6.4"
libc = "0.2.148"
bytemuck = { version = "1.14", features = [ "derive" ] }
itertools = "0.11.0"

[lib]
name = "cappy3ds"
crate-type = ["staticlib", "cdylib", "lib"]
6 changes: 3 additions & 3 deletions Cappy3ds/src/capture/katsukitty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ pub fn do_capture() {

// bleh apparently relesase runs fast enough to break this
// add in some sleeps
if fpga::check_fpga_programmed(&mut handle) {
} else {
//if fpga::check_fpga_programmed(&mut handle) {
//} else {
fpga::read_eeprom(&mut handle);
fpga::configure_fpga(&mut handle, bitstream.data.to_vec());
fpga::configure_port(&mut handle);
}
//}

fpga::fifo_start(&mut handle);

Expand Down
57 changes: 0 additions & 57 deletions Cappy3ds/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,58 +1 @@
use futures::executor;
use raw_window_handle::{
AppKitDisplayHandle, AppKitWindowHandle, HasRawDisplayHandle, HasRawWindowHandle,
RawDisplayHandle, RawWindowHandle,
};
use std::ffi;

mod render;

pub use render::render::State;

mod capture;

#[no_mangle]
pub extern "C" fn send_window(app_kit_nsview: *mut ffi::c_void) {
let window = Window {
ns_view: app_kit_nsview,
};

let res = State::new(&window);
let mut v = executor::block_on(res);

v.render();
}

pub fn send_raw_window<
W: raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle,
>(
window: &W,
) {
//capture::do_capture();

let res = State::new(&window);
let mut v = executor::block_on(res);

v.render();
}

pub struct Window {
//id: usize,
// ns_window: *mut ffi::c_void,
ns_view: *mut ffi::c_void,
}

unsafe impl HasRawDisplayHandle for Window {
fn raw_display_handle(&self) -> RawDisplayHandle {
RawDisplayHandle::AppKit(AppKitDisplayHandle::empty())
}
}

unsafe impl HasRawWindowHandle for Window {
fn raw_window_handle(&self) -> RawWindowHandle {
let mut handle = AppKitWindowHandle::empty();
// handle.ns_window = self.ns_window;
handle.ns_view = self.ns_view;
RawWindowHandle::AppKit(handle)
}
}
1 change: 0 additions & 1 deletion Cappy3ds/src/render/mod.rs

This file was deleted.

20 changes: 13 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]

members = [
"Cappy3ds",
"cappy3ds",
"cappy3ds_render",
"simple_win"
]
]
6 changes: 3 additions & 3 deletions build_macos_lib.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cargo build -p cappy3ds
cp ./target/debug/libcappy3ds.dylib ./macos/
cbindgen --config ./Cappy3ds/cbindgen.toml --lang c --crate cappy3ds --output ./bindings.h
cargo build -p cappy3ds_render
cp ./target/debug/libcappy3ds_render.dylib ./macos/
cbindgen --config ./cappy3ds_render/cbindgen.toml --lang c --crate cappy3ds_render --output ./bindings.h
19 changes: 19 additions & 0 deletions cappy3ds_render/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "cappy3ds_render"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bytemuck = { version = "1.14", features = [ "derive" ] }
env_logger = "0.10"
log = "0.4"
wgpu = "0.17"
raw-window-handle = "0.5.2"
image = "0.24.7"
futures = "0.3.28"

[lib]
name = "cappy3ds_render"
crate-type = ["staticlib", "cdylib", "lib"]
File renamed without changes.
57 changes: 57 additions & 0 deletions cappy3ds_render/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use futures::executor;
use raw_window_handle::{
AppKitDisplayHandle, AppKitWindowHandle, HasRawDisplayHandle, HasRawWindowHandle,
RawDisplayHandle, RawWindowHandle,
};
use std::ffi;

mod render;

pub use render::State;


#[no_mangle]
pub extern "C" fn send_window(app_kit_nsview: *mut ffi::c_void) {
let window = Window {
ns_view: app_kit_nsview,
};

let res = State::new(&window);
let mut v = executor::block_on(res);

v.render();
}

pub fn send_raw_window<
W: raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle,
>(
window: &W,
) {
//capture::do_capture();

let res = State::new(&window);
let mut v = executor::block_on(res);

v.render();
}

pub struct Window {
//id: usize,
// ns_window: *mut ffi::c_void,
ns_view: *mut ffi::c_void,
}

unsafe impl HasRawDisplayHandle for Window {
fn raw_display_handle(&self) -> RawDisplayHandle {
RawDisplayHandle::AppKit(AppKitDisplayHandle::empty())
}
}

unsafe impl HasRawWindowHandle for Window {
fn raw_window_handle(&self) -> RawWindowHandle {
let mut handle = AppKitWindowHandle::empty();
// handle.ns_window = self.ns_window;
handle.ns_view = self.ns_view;
RawWindowHandle::AppKit(handle)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl State {

let num_indices = INDICES.len() as u32;

let diffuse_bytes = include_bytes!("../../resources/test/katsu_example_image.png");
let diffuse_bytes = include_bytes!("../resources/test/katsu_example_image.png");
let diffuse_image = image::load_from_memory(diffuse_bytes).unwrap();
let diffuse_rgba = diffuse_image.to_rgba8();

Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions macos/Cappy3ds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
670A0A902AC14FEE00E03E0D /* Cappy3dsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 670A0A8F2AC14FEE00E03E0D /* Cappy3dsTests.swift */; };
670A0A9A2AC14FEE00E03E0D /* Cappy3dsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 670A0A992AC14FEE00E03E0D /* Cappy3dsUITests.swift */; };
670A0A9C2AC14FEE00E03E0D /* Cappy3dsUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 670A0A9B2AC14FEE00E03E0D /* Cappy3dsUITestsLaunchTests.swift */; };
67A0F4582AC22EFB00B072B4 /* libcappy3ds.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 67A0F4572AC22EFB00B072B4 /* libcappy3ds.dylib */; };
67C897D02AD4DF6100F97849 /* libcappy3ds.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 67A0F4572AC22EFB00B072B4 /* libcappy3ds.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
67A620A42AD77AD100BD2349 /* libcappy3ds_render.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 67A620A32AD77AD100BD2349 /* libcappy3ds_render.dylib */; };
67A620A52AD77AEC00BD2349 /* libcappy3ds_render.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 67A620A32AD77AD100BD2349 /* libcappy3ds_render.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -42,7 +42,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
67C897D02AD4DF6100F97849 /* libcappy3ds.dylib in CopyFiles */,
67A620A52AD77AEC00BD2349 /* libcappy3ds_render.dylib in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -62,15 +62,15 @@
670A0A9B2AC14FEE00E03E0D /* Cappy3dsUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cappy3dsUITestsLaunchTests.swift; sourceTree = "<group>"; };
670A0AAB2AC153D800E03E0D /* Cappy3ds-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Cappy3ds-Bridging-Header.h"; sourceTree = "<group>"; };
67A0F4502AC156D400B072B4 /* bindings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = bindings.h; path = ../../bindings.h; sourceTree = "<group>"; };
67A0F4572AC22EFB00B072B4 /* libcappy3ds.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libcappy3ds.dylib; sourceTree = SOURCE_ROOT; };
67A620A32AD77AD100BD2349 /* libcappy3ds_render.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libcappy3ds_render.dylib; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
670A0A772AC14FED00E03E0D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
67A0F4582AC22EFB00B072B4 /* libcappy3ds.dylib in Frameworks */,
67A620A42AD77AD100BD2349 /* libcappy3ds_render.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -114,7 +114,7 @@
670A0A7C2AC14FED00E03E0D /* Cappy3ds */ = {
isa = PBXGroup;
children = (
67A0F4572AC22EFB00B072B4 /* libcappy3ds.dylib */,
67A620A32AD77AD100BD2349 /* libcappy3ds_render.dylib */,
67A0F4502AC156D400B072B4 /* bindings.h */,
670A0A7D2AC14FED00E03E0D /* Cappy3dsApp.swift */,
670A0A7F2AC14FED00E03E0D /* ContentView.swift */,
Expand Down
2 changes: 1 addition & 1 deletion simple_win/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cappy3ds = { path = "../Cappy3ds" }
cappy3ds_render = { path = "../cappy3ds_render" }
winit = "0.28"
env_logger = "0.10"
log = "0.4"
4 changes: 2 additions & 2 deletions simple_win/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use winit::{
window::WindowBuilder,
};

use cappy3ds;
use cappy3ds_render;

pub fn run() {
env_logger::init();
let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();

cappy3ds::send_raw_window(&window);
cappy3ds_render::send_raw_window(&window);

event_loop.run(move |event, _, control_flow| match event {
Event::WindowEvent {
Expand Down

0 comments on commit 18b4130

Please sign in to comment.