diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index 091e7856650..d5dc0c364cc 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -438,7 +438,7 @@ pub trait IdentityHandler: Debug { } impl IdentityHandler for Mutex { - type Input = PhantomData; + type Input = (); fn process(&self, _id: Self::Input, backend: Backend) -> I { self.lock().alloc(backend) } diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 870d03d106a..3166f0fc047 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -15,7 +15,6 @@ use std::{ error::Error, fmt, future::{ready, Ready}, - marker::PhantomData, ops::Range, slice, sync::Arc, @@ -69,9 +68,7 @@ impl Context { #[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))] pub fn enumerate_adapters(&self, backends: wgt::Backends) -> Vec { self.0 - .enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| { - PhantomData - })) + .enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| ())) } #[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))] @@ -79,7 +76,7 @@ impl Context { &self, hal_adapter: hal::ExposedAdapter, ) -> wgc::id::AdapterId { - self.0.create_adapter_from_hal(hal_adapter, PhantomData) + self.0.create_adapter_from_hal(hal_adapter, ()) } pub unsafe fn adapter_as_hal) -> R, R>( @@ -105,7 +102,7 @@ impl Context { hal_device, &desc.map_label(|l| l.map(Borrowed)), trace_dir, - PhantomData, + (), ); if let Some(err) = error { self.handle_error_fatal(err, "Adapter::create_device_from_hal"); @@ -130,7 +127,7 @@ impl Context { hal_texture, device.id, &desc.map_label(|l| l.map(Borrowed)), - PhantomData, + (), ); if let Some(cause) = error { self.handle_error( @@ -177,7 +174,7 @@ impl Context { self: &Arc, layer: *mut std::ffi::c_void, ) -> crate::Surface { - let id = self.0.instance_create_surface_metal(layer, PhantomData); + let id = self.0.instance_create_surface_metal(layer, ()); crate::Surface { context: Arc::clone(self), id: Surface { @@ -192,7 +189,7 @@ impl Context { self: &Arc, canvas: &web_sys::HtmlCanvasElement, ) -> Surface { - let id = self.0.create_surface_webgl_canvas(canvas, PhantomData); + let id = self.0.create_surface_webgl_canvas(canvas, ()); Surface { id, configured_device: Mutex::default(), @@ -204,9 +201,7 @@ impl Context { self: &Arc, canvas: &web_sys::OffscreenCanvas, ) -> Surface { - let id = self - .0 - .create_surface_webgl_offscreen_canvas(canvas, PhantomData); + let id = self.0.create_surface_webgl_offscreen_canvas(canvas, ()); Surface { id, configured_device: Mutex::default(), @@ -218,9 +213,7 @@ impl Context { self: &Arc, visual: *mut std::ffi::c_void, ) -> crate::Surface { - let id = self - .0 - .instance_create_surface_from_visual(visual, PhantomData); + let id = self.0.instance_create_surface_from_visual(visual, ()); crate::Surface { context: Arc::clone(self), id: Surface { @@ -853,7 +846,7 @@ impl crate::Context for Context { handle: &(impl raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle), ) -> Self::SurfaceId { Surface { - id: self.0.instance_create_surface(handle, PhantomData), + id: self.0.instance_create_surface(handle, ()), configured_device: Mutex::new(None), } } @@ -868,7 +861,7 @@ impl crate::Context for Context { force_fallback_adapter: options.force_fallback_adapter, compatible_surface: options.compatible_surface.map(|surface| surface.id.id), }, - wgc::instance::AdapterInputs::Mask(wgt::Backends::all(), |_| PhantomData), + wgc::instance::AdapterInputs::Mask(wgt::Backends::all(), |_| ()), ); ready(id.ok()) } @@ -892,7 +885,7 @@ impl crate::Context for Context { *adapter, &desc.map_label(|l| l.map(Borrowed)), trace_dir, - PhantomData + () )); if let Some(err) = error { log::error!("Error in Adapter::request_device: {}", err); @@ -1022,7 +1015,7 @@ impl crate::Context for Context { .lock() .expect("Surface was not configured?"); match wgc::gfx_select!( - device_id => global.surface_get_current_texture(surface.id, PhantomData) + device_id => global.surface_get_current_texture(surface.id, ()) ) { Ok(wgc::present::SurfaceOutput { status, texture_id }) => ( texture_id.map(|id| Texture { @@ -1127,7 +1120,7 @@ impl crate::Context for Context { ShaderSource::Naga(module) => wgc::pipeline::ShaderModuleSource::Naga(module), }; let (id, error) = wgc::gfx_select!( - device.id => global.device_create_shader_module(device.id, &descriptor, source, PhantomData) + device.id => global.device_create_shader_module(device.id, &descriptor, source, ()) ); if let Some(cause) = error { self.handle_error( @@ -1154,7 +1147,7 @@ impl crate::Context for Context { shader_bound_checks: wgt::ShaderBoundChecks::unchecked(), }; let (id, error) = wgc::gfx_select!( - device.id => global.device_create_shader_module_spirv(device.id, &descriptor, Borrowed(&desc.source), PhantomData) + device.id => global.device_create_shader_module_spirv(device.id, &descriptor, Borrowed(&desc.source), ()) ); if let Some(cause) = error { self.handle_error( @@ -1179,7 +1172,7 @@ impl crate::Context for Context { entries: Borrowed(desc.entries), }; let (id, error) = wgc::gfx_select!( - device.id => global.device_create_bind_group_layout(device.id, &descriptor, PhantomData) + device.id => global.device_create_bind_group_layout(device.id, &descriptor, ()) ); if let Some(cause) = error { self.handle_error( @@ -1280,7 +1273,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_bind_group( device.id, &descriptor, - PhantomData + () )); if let Some(cause) = error { self.handle_error( @@ -1323,7 +1316,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_pipeline_layout( device.id, &descriptor, - PhantomData + () )); if let Some(cause) = error { self.handle_error( @@ -1358,8 +1351,8 @@ impl crate::Context for Context { let implicit_pipeline_ids = match desc.layout { Some(_) => None, None => Some(wgc::device::ImplicitPipelineIds { - root_id: PhantomData, - group_ids: &[PhantomData; wgc::MAX_BIND_GROUPS], + root_id: (), + group_ids: &[(); wgc::MAX_BIND_GROUPS], }), }; let descriptor = pipe::RenderPipelineDescriptor { @@ -1389,7 +1382,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_render_pipeline( device.id, &descriptor, - PhantomData, + (), implicit_pipeline_ids )); if let Some(cause) = error { @@ -1418,8 +1411,8 @@ impl crate::Context for Context { let implicit_pipeline_ids = match desc.layout { Some(_) => None, None => Some(wgc::device::ImplicitPipelineIds { - root_id: PhantomData, - group_ids: &[PhantomData; wgc::MAX_BIND_GROUPS], + root_id: (), + group_ids: &[(); wgc::MAX_BIND_GROUPS], }), }; let descriptor = pipe::ComputePipelineDescriptor { @@ -1435,7 +1428,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_compute_pipeline( device.id, &descriptor, - PhantomData, + (), implicit_pipeline_ids )); if let Some(cause) = error { @@ -1467,7 +1460,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_buffer( device.id, &desc.map_label(|l| l.map(Borrowed)), - PhantomData + () )); if let Some(cause) = error { self.handle_error( @@ -1493,7 +1486,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_texture( device.id, &desc.map_label(|l| l.map(Borrowed)), - PhantomData + () )); if let Some(cause) = error { self.handle_error( @@ -1536,7 +1529,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_sampler( device.id, &descriptor, - PhantomData + () )); if let Some(cause) = error { self.handle_error( @@ -1559,7 +1552,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_query_set( device.id, &desc.map_label(|l| l.map(Borrowed)), - PhantomData + () )); if let Some(cause) = error { self.handle_error_nolabel(&device.error_sink, cause, "Device::create_query_set"); @@ -1576,7 +1569,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(device.id => global.device_create_command_encoder( device.id, &desc.map_label(|l| l.map(Borrowed)), - PhantomData + () )); if let Some(cause) = error { self.handle_error( @@ -1742,7 +1735,7 @@ impl crate::Context for Context { }; let global = &self.0; let (id, error) = wgc::gfx_select!( - texture.id => global.texture_create_view(texture.id, &descriptor, PhantomData) + texture.id => global.texture_create_view(texture.id, &descriptor, ()) ); if let Some(cause) = error { self.handle_error( @@ -1848,7 +1841,7 @@ impl crate::Context for Context { index: u32, ) -> Self::BindGroupLayoutId { let global = &self.0; - let (id, error) = wgc::gfx_select!(*pipeline => global.compute_pipeline_get_bind_group_layout(*pipeline, index, PhantomData)); + let (id, error) = wgc::gfx_select!(*pipeline => global.compute_pipeline_get_bind_group_layout(*pipeline, index, ())); if let Some(err) = error { panic!("Error reflecting bind group {}: {}", index, err); } @@ -1860,7 +1853,7 @@ impl crate::Context for Context { index: u32, ) -> Self::BindGroupLayoutId { let global = &self.0; - let (id, error) = wgc::gfx_select!(*pipeline => global.render_pipeline_get_bind_group_layout(*pipeline, index, PhantomData)); + let (id, error) = wgc::gfx_select!(*pipeline => global.render_pipeline_get_bind_group_layout(*pipeline, index, ())); if let Some(err) = error { panic!("Error reflecting bind group {}: {}", index, err); } @@ -2183,7 +2176,7 @@ impl crate::Context for Context { let (id, error) = wgc::gfx_select!(encoder.parent() => global.render_bundle_encoder_finish( encoder, &desc.map_label(|l| l.map(Borrowed)), - PhantomData + () )); if let Some(err) = error { self.handle_error_fatal(err, "RenderBundleEncoder::finish"); @@ -2230,7 +2223,7 @@ impl crate::Context for Context { ) -> QueueWriteBuffer { let global = &self.0; match wgc::gfx_select!( - *queue => global.queue_create_staging_buffer(*queue, size, PhantomData) + *queue => global.queue_create_staging_buffer(*queue, size, ()) ) { Ok((buffer_id, ptr)) => QueueWriteBuffer { buffer_id,