diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index 9f574d6e57..27c1157ab3 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -80,9 +80,6 @@ async fn setup(title: &str) -> Setup { ); }; - #[cfg(target_arch = "wasm32")] - console_log::init().expect("could not initialize logger"); - let event_loop = EventLoop::new(); let mut builder = winit::window::WindowBuilder::new(); builder = builder.with_title(title); @@ -93,6 +90,22 @@ async fn setup(title: &str) -> Setup { } let window = builder.build(&event_loop).unwrap(); + #[cfg(target_arch = "wasm32")] + { + use winit::platform::web::WindowExtWebSys; + console_log::init().expect("could not initialize logger"); + std::panic::set_hook(Box::new(console_error_panic_hook::hook)); + // On wasm, append the canvas to the document body + web_sys::window() + .and_then(|win| win.document()) + .and_then(|doc| doc.body()) + .and_then(|body| { + body.append_child(&web_sys::Element::from(window.canvas())) + .ok() + }) + .expect("couldn't append canvas to document body"); + } + log::info!("Initializing the surface..."); let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY); @@ -101,7 +114,6 @@ async fn setup(title: &str) -> Setup { let surface = instance.create_surface(&window); (size, surface) }; - let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::Default, @@ -109,7 +121,6 @@ async fn setup(title: &str) -> Setup { }) .await .unwrap(); - let optional_features = E::optional_features(); let required_features = E::required_features(); let adapter_features = adapter.features(); @@ -168,7 +179,6 @@ fn start( #[cfg(target_arch = "wasm32")] let spawner = { use futures::{future::LocalFutureObj, task::SpawnError}; - use winit::platform::web::WindowExtWebSys; struct WebSpawner {} impl LocalSpawn for WebSpawner { @@ -180,18 +190,6 @@ fn start( } } - std::panic::set_hook(Box::new(console_error_panic_hook::hook)); - - // On wasm, append the canvas to the document body - web_sys::window() - .and_then(|win| win.document()) - .and_then(|doc| doc.body()) - .and_then(|body| { - body.append_child(&web_sys::Element::from(window.canvas())) - .ok() - }) - .expect("couldn't append canvas to document body"); - WebSpawner {} }; diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 73258f8258..3848c5eba0 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -90,15 +90,15 @@ impl crate::ComputePassInner for ComputePass { } fn insert_debug_marker(&mut self, _label: &str) { - unimplemented!() + // TODO } fn push_debug_group(&mut self, _group_label: &str) { - unimplemented!() + // TODO } fn pop_debug_group(&mut self) { - unimplemented!() + // TODO } fn dispatch(&mut self, x: u32, y: u32, z: u32) { @@ -263,15 +263,15 @@ impl crate::RenderPassInner for RenderPass { } fn insert_debug_marker(&mut self, _label: &str) { - unimplemented!() + // TODO } fn push_debug_group(&mut self, _group_label: &str) { - unimplemented!() + // TODO } fn pop_debug_group(&mut self) { - unimplemented!() + // TODO } fn execute_bundles<'a, I: Iterator>(&mut self, _render_bundles: I) { @@ -1465,13 +1465,13 @@ impl crate::Context for Context { } fn command_encoder_insert_debug_marker(&self, encoder: &Self::CommandEncoderId, label: &str) { - unimplemented!() + // TODO } fn command_encoder_push_debug_group(&self, encoder: &Self::CommandEncoderId, label: &str) { - unimplemented!() + // TODO } fn command_encoder_pop_debug_group(&self, encoder: &Self::CommandEncoderId) { - unimplemented!() + // TODO } fn render_bundle_encoder_finish(