diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 4569cad4bf..cf0c64d249 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -68,13 +68,11 @@ impl Context { &self.0 } - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] pub fn enumerate_adapters(&self, backends: wgt::Backends) -> Vec { self.0 .enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| ())) } - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] pub unsafe fn create_adapter_from_hal( &self, hal_adapter: hal::ExposedAdapter, @@ -93,7 +91,6 @@ impl Context { } } - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] pub unsafe fn create_device_from_hal( &self, adapter: &wgc::id::AdapterId, @@ -152,7 +149,6 @@ impl Context { } } - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] pub unsafe fn device_as_hal) -> R, R>( &self, device: &Device, @@ -164,7 +160,6 @@ impl Context { } } - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] pub unsafe fn surface_as_hal_mut< A: wgc::hub::HalApi, F: FnOnce(Option<&mut A::Surface>) -> R, @@ -180,7 +175,6 @@ impl Context { } } - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] pub unsafe fn texture_as_hal)>( &self, texture: &Texture, @@ -192,7 +186,6 @@ impl Context { } } - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] pub fn generate_report(&self) -> wgc::hub::GlobalReport { self.0.generate_report() } @@ -209,11 +202,7 @@ impl Context { } } - #[cfg(all( - target_arch = "wasm32", - feature = "webgl", - not(target_os = "emscripten") - ))] + #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] pub fn instance_create_surface_from_canvas( &self, canvas: &web_sys::HtmlCanvasElement, @@ -228,11 +217,7 @@ impl Context { }) } - #[cfg(all( - target_arch = "wasm32", - feature = "webgl", - not(target_os = "emscripten") - ))] + #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] pub fn instance_create_surface_from_offscreen_canvas( &self, canvas: &web_sys::OffscreenCanvas, diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 5cc593eb14..77c09d834b 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -1406,7 +1406,11 @@ impl Instance { /// # Arguments /// /// - `backends` - Backends from which to enumerate adapters. - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + #[cfg(any( + not(target_arch = "wasm32"), + target_os = "emscripten", + feature = "webgl" + ))] pub fn enumerate_adapters(&self, backends: Backends) -> impl Iterator { let context = Arc::clone(&self.context); self.context @@ -1445,7 +1449,11 @@ impl Instance { /// # Safety /// /// `hal_adapter` must be created from this instance internal handle. - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + #[cfg(any( + not(target_arch = "wasm32"), + target_os = "emscripten", + feature = "webgl" + ))] pub unsafe fn create_adapter_from_hal( &self, hal_adapter: hal::ExposedAdapter, @@ -1671,7 +1679,11 @@ impl Instance { } /// Generates memory report. - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + #[cfg(any( + not(target_arch = "wasm32"), + target_os = "emscripten", + feature = "webgl" + ))] pub fn generate_report(&self) -> wgc::hub::GlobalReport { self.context .as_any() @@ -1742,7 +1754,11 @@ impl Adapter { /// /// - `hal_device` must be created from this adapter internal handle. /// - `desc.features` must be a subset of `hal_device` features. - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + #[cfg(any( + not(target_arch = "wasm32"), + target_os = "emscripten", + feature = "webgl" + ))] pub unsafe fn create_device_from_hal( &self, hal_device: hal::OpenDevice, @@ -2246,7 +2262,11 @@ impl Device { /// - The raw handle passed to the callback must not be manually destroyed. /// /// [`A::Device`]: hal::Api::Device - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + #[cfg(any( + not(target_arch = "wasm32"), + target_os = "emscripten", + feature = "webgl" + ))] pub unsafe fn as_hal) -> R, R>( &self, hal_device_callback: F, @@ -2584,7 +2604,11 @@ impl Texture { /// # Safety /// /// - The raw handle obtained from the hal Texture must not be manually destroyed - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + #[cfg(any( + not(target_arch = "wasm32"), + target_os = "emscripten", + feature = "webgl" + ))] pub unsafe fn as_hal)>( &self, hal_texture_callback: F, @@ -4193,7 +4217,11 @@ impl Surface { /// # Safety /// /// - The raw handle obtained from the hal Surface must not be manually destroyed - #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + #[cfg(any( + not(target_arch = "wasm32"), + target_os = "emscripten", + feature = "webgl" + ))] pub unsafe fn as_hal_mut) -> R, R>( &mut self, hal_surface_callback: F,