diff --git a/shell.nix b/shell.nix index c9271124..e8ba4571 100644 --- a/shell.nix +++ b/shell.nix @@ -14,6 +14,7 @@ with (import { ]; targets = ["wasm32-unknown-unknown"]; })) + trunk udev ]; diff --git a/tetanes/Cargo.toml b/tetanes/Cargo.toml index 0627f401..4adeb0fb 100644 --- a/tetanes/Cargo.toml +++ b/tetanes/Cargo.toml @@ -76,7 +76,11 @@ tracing.workspace = true tracing-subscriber.workspace = true uuid = { version = "1.10", features = ["v4", "fast-rng", "serde"] } webbrowser = { version = "1.0", features = ["hardened", "disable-wsl"] } -wgpu = { version = "23.0", features = ["webgl", "webgpu"] } +wgpu = { version = "23.0", features = [ + "webgl", + "webgpu", + "fragile-send-sync-non-atomic-wasm", # Safe because we're not enabling atomics +] } winit = { version = "0.30", features = ["serde"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/tetanes/src/nes/renderer/gui/ppu_viewer.rs b/tetanes/src/nes/renderer/gui/ppu_viewer.rs index 26ca027b..b56608d5 100644 --- a/tetanes/src/nes/renderer/gui/ppu_viewer.rs +++ b/tetanes/src/nes/renderer/gui/ppu_viewer.rs @@ -345,10 +345,6 @@ impl PpuViewer { let open = Arc::clone(&self.open); let state = Arc::clone(&self.state); - // let Some(cfg) = self.resources.take() else { - // warn!("PpuViewer::prepare was not called with required resources"); - // return; - // }; let mut viewport_builder = egui::ViewportBuilder::default() .with_title(Self::TITLE) @@ -357,20 +353,15 @@ impl PpuViewer { viewport_builder = viewport_builder.with_always_on_top(); } - ctx.show_viewport_deferred(self.id, viewport_builder, move |ctx, class| { - if class == ViewportClass::Embedded { - let mut window_open = open.load(Ordering::Acquire); - egui::Window::new(PpuViewer::TITLE) - .open(&mut window_open) - .show(ctx, |ui| state.lock().ui(ui, opts.enabled)); - open.store(window_open, Ordering::Release); - } else { - CentralPanel::default().show(ctx, |ui| state.lock().ui(ui, opts.enabled)); - if ctx.input(|i| i.viewport().close_requested()) { - open.store(false, Ordering::Release); - } - } - }); + let show_viewport = move |ctx: &Context, _: ViewportClass| { + let mut window_open = open.load(Ordering::Acquire); + egui::Window::new(PpuViewer::TITLE) + .open(&mut window_open) + .show(ctx, |ui| state.lock().ui(ui, opts.enabled)); + open.store(window_open, Ordering::Release); + }; + + ctx.show_viewport_deferred(self.id, viewport_builder, show_viewport); } } diff --git a/tetanes/src/sys/platform/wasm.rs b/tetanes/src/sys/platform/wasm.rs index 34539222..f1656c8e 100644 --- a/tetanes/src/sys/platform/wasm.rs +++ b/tetanes/src/sys/platform/wasm.rs @@ -356,7 +356,7 @@ pub mod renderer { (viewport_ui_cb, raw_input.take()) }; - let mut output = ctx.run(raw_input, |ctx| match viewport_ui_cb { + let mut output = ctx.run(raw_input, |ctx| match &viewport_ui_cb { Some(viewport_ui_cb) => viewport_ui_cb(ctx), None => gui.borrow_mut().ui(ctx, None), });