diff --git a/deno_webgpu/binding.rs b/deno_webgpu/binding.rs index 5d582e900..5f1abde2b 100644 --- a/deno_webgpu/binding.rs +++ b/deno_webgpu/binding.rs @@ -21,8 +21,7 @@ impl Resource for WebGpuBindGroupLayout { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.bind_group_layout_drop(self.1)); + gfx_select!(self.1 => self.0.bind_group_layout_drop(self.1)); } } @@ -36,8 +35,7 @@ impl Resource for WebGpuBindGroup { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.bind_group_drop(self.1)); + gfx_select!(self.1 => self.0.bind_group_drop(self.1)); } } diff --git a/deno_webgpu/buffer.rs b/deno_webgpu/buffer.rs index 171642e1d..b46ceb197 100644 --- a/deno_webgpu/buffer.rs +++ b/deno_webgpu/buffer.rs @@ -26,8 +26,7 @@ impl Resource for WebGpuBuffer { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.buffer_drop(self.1, true)); + gfx_select!(self.1 => self.0.buffer_drop(self.1, true)); } } diff --git a/deno_webgpu/bundle.rs b/deno_webgpu/bundle.rs index b053cf265..7e37bc649 100644 --- a/deno_webgpu/bundle.rs +++ b/deno_webgpu/bundle.rs @@ -30,8 +30,7 @@ impl Resource for WebGpuRenderBundle { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.render_bundle_drop(self.1)); + gfx_select!(self.1 => self.0.render_bundle_drop(self.1)); } } diff --git a/deno_webgpu/command_encoder.rs b/deno_webgpu/command_encoder.rs index 7079fd96c..33f271ce9 100644 --- a/deno_webgpu/command_encoder.rs +++ b/deno_webgpu/command_encoder.rs @@ -23,8 +23,7 @@ impl Resource for WebGpuCommandEncoder { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.command_encoder_drop(self.1)); + gfx_select!(self.1 => self.0.command_encoder_drop(self.1)); } } @@ -39,8 +38,7 @@ impl Resource for WebGpuCommandBuffer { fn close(self: Rc) { if let Some(id) = *self.1.borrow() { - let instance = &self.0; - gfx_select!(id => instance.command_buffer_drop(id)); + gfx_select!(id => self.0.command_buffer_drop(id)); } } } diff --git a/deno_webgpu/lib.rs b/deno_webgpu/lib.rs index 15151ce95..bc6d7a2ae 100644 --- a/deno_webgpu/lib.rs +++ b/deno_webgpu/lib.rs @@ -22,23 +22,31 @@ use error::WebGpuResult; #[macro_use] mod macros { macro_rules! gfx_select { - ($id:expr => $global:ident.$method:ident( $($param:expr),* )) => { + ($id:expr => $p0:ident.$p1:tt.$method:ident $params:tt) => { + gfx_select!($id => {$p0.$p1}, $method $params) + }; + + ($id:expr => $p0:ident.$method:ident $params:tt) => { + gfx_select!($id => {$p0}, $method $params) + }; + + ($id:expr => {$($c:tt)*}, $method:ident $params:tt) => { match $id.backend() { #[cfg(any( all(not(target_arch = "wasm32"), not(target_os = "ios"), not(target_os = "macos")), feature = "vulkan-portability" ))] - wgpu_types::Backend::Vulkan => $global.$method::( $($param),* ), + wgpu_types::Backend::Vulkan => $($c)*.$method:: $params, #[cfg(all(not(target_arch = "wasm32"), any(target_os = "ios", target_os = "macos")))] - wgpu_types::Backend::Metal => $global.$method::( $($param),* ), + wgpu_types::Backend::Metal => $($c)*.$method:: $params, #[cfg(all(not(target_arch = "wasm32"), windows))] - wgpu_types::Backend::Dx12 => $global.$method::( $($param),* ), + wgpu_types::Backend::Dx12 => $($c)*.$method:: $params, #[cfg(any( all(unix, not(target_os = "macos"), not(target_os = "ios")), feature = "angle", target_arch = "wasm32" ))] - wgpu_types::Backend::Gl => $global.$method::( $($param),+ ), + wgpu_types::Backend::Gl => $($c)*.$method:: $params, other => panic!("Unexpected backend {:?}", other), } }; @@ -98,8 +106,7 @@ impl Resource for WebGpuAdapter { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.adapter_drop(self.1)); + gfx_select!(self.1 => self.0.adapter_drop(self.1)); } } @@ -110,8 +117,7 @@ impl Resource for WebGpuDevice { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.device_drop(self.1)); + gfx_select!(self.1 => self.0.device_drop(self.1)); } } @@ -122,8 +128,7 @@ impl Resource for WebGpuQuerySet { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.query_set_drop(self.1)); + gfx_select!(self.1 => self.0.query_set_drop(self.1)); } } diff --git a/deno_webgpu/pipeline.rs b/deno_webgpu/pipeline.rs index e0555b9d1..bf98b690b 100644 --- a/deno_webgpu/pipeline.rs +++ b/deno_webgpu/pipeline.rs @@ -25,8 +25,7 @@ impl Resource for WebGpuPipelineLayout { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.pipeline_layout_drop(self.1)); + gfx_select!(self.1 => self.0.pipeline_layout_drop(self.1)); } } @@ -40,8 +39,7 @@ impl Resource for WebGpuComputePipeline { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.compute_pipeline_drop(self.1)); + gfx_select!(self.1 => self.0.compute_pipeline_drop(self.1)); } } @@ -55,8 +53,7 @@ impl Resource for WebGpuRenderPipeline { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.render_pipeline_drop(self.1)); + gfx_select!(self.1 => self.0.render_pipeline_drop(self.1)); } } diff --git a/deno_webgpu/sampler.rs b/deno_webgpu/sampler.rs index 6f9b66ad4..5876498b2 100644 --- a/deno_webgpu/sampler.rs +++ b/deno_webgpu/sampler.rs @@ -21,8 +21,7 @@ impl Resource for WebGpuSampler { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.sampler_drop(self.1)); + gfx_select!(self.1 => self.0.sampler_drop(self.1)); } } diff --git a/deno_webgpu/shader.rs b/deno_webgpu/shader.rs index f7cce2428..f091b15f8 100644 --- a/deno_webgpu/shader.rs +++ b/deno_webgpu/shader.rs @@ -20,8 +20,7 @@ impl Resource for WebGpuShaderModule { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.shader_module_drop(self.1)); + gfx_select!(self.1 => self.0.shader_module_drop(self.1)); } } diff --git a/deno_webgpu/texture.rs b/deno_webgpu/texture.rs index 5eadd5b3c..8e1afa492 100644 --- a/deno_webgpu/texture.rs +++ b/deno_webgpu/texture.rs @@ -39,8 +39,7 @@ impl Resource for WebGpuTextureView { } fn close(self: Rc) { - let instance = &self.0; - gfx_select!(self.1 => instance.texture_view_drop(self.1, true)).unwrap(); + gfx_select!(self.1 => self.0.texture_view_drop(self.1, true)).unwrap(); } } diff --git a/wgpu-core/src/error.rs b/wgpu-core/src/error.rs index a6e3d3158..4a33207ca 100644 --- a/wgpu-core/src/error.rs +++ b/wgpu-core/src/error.rs @@ -24,32 +24,27 @@ impl<'a> ErrorFormatter<'a> { } pub fn bind_group_label(&mut self, id: &crate::id::BindGroupId) { - let global = self.global; - let label: String = gfx_select!(id => global.bind_group_label(*id)); + let label: String = gfx_select!(id => self.global.bind_group_label(*id)); self.label("bind group", &label); } pub fn bind_group_layout_label(&mut self, id: &crate::id::BindGroupLayoutId) { - let global = self.global; - let label: String = gfx_select!(id => global.bind_group_layout_label(*id)); + let label: String = gfx_select!(id => self.global.bind_group_layout_label(*id)); self.label("bind group layout", &label); } pub fn render_pipeline_label(&mut self, id: &crate::id::RenderPipelineId) { - let global = self.global; - let label: String = gfx_select!(id => global.render_pipeline_label(*id)); + let label: String = gfx_select!(id => self.global.render_pipeline_label(*id)); self.label("render pipeline", &label); } pub fn compute_pipeline_label(&mut self, id: &crate::id::ComputePipelineId) { - let global = self.global; - let label: String = gfx_select!(id => global.compute_pipeline_label(*id)); + let label: String = gfx_select!(id => self.global.compute_pipeline_label(*id)); self.label("compute pipeline", &label); } pub fn buffer_label_with_key(&mut self, id: &crate::id::BufferId, key: &str) { - let global = self.global; - let label: String = gfx_select!(id => global.buffer_label(*id)); + let label: String = gfx_select!(id => self.global.buffer_label(*id)); self.label(key, &label); } @@ -58,8 +53,7 @@ impl<'a> ErrorFormatter<'a> { } pub fn texture_label_with_key(&mut self, id: &crate::id::TextureId, key: &str) { - let global = self.global; - let label: String = gfx_select!(id => global.texture_label(*id)); + let label: String = gfx_select!(id => self.global.texture_label(*id)); self.label(key, &label); } @@ -68,8 +62,7 @@ impl<'a> ErrorFormatter<'a> { } pub fn texture_view_label_with_key(&mut self, id: &crate::id::TextureViewId, key: &str) { - let global = self.global; - let label: String = gfx_select!(id => global.texture_view_label(*id)); + let label: String = gfx_select!(id => self.global.texture_view_label(*id)); self.label(key, &label); } @@ -78,20 +71,17 @@ impl<'a> ErrorFormatter<'a> { } pub fn sampler_label(&mut self, id: &crate::id::SamplerId) { - let global = self.global; - let label: String = gfx_select!(id => global.sampler_label(*id)); + let label: String = gfx_select!(id => self.global.sampler_label(*id)); self.label("sampler", &label); } pub fn command_buffer_label(&mut self, id: &crate::id::CommandBufferId) { - let global = self.global; - let label: String = gfx_select!(id => global.command_buffer_label(*id)); + let label: String = gfx_select!(id => self.global.command_buffer_label(*id)); self.label("command buffer", &label); } pub fn query_set_label(&mut self, id: &crate::id::QuerySetId) { - let global = self.global; - let label: String = gfx_select!(id => global.query_set_label(*id)); + let label: String = gfx_select!(id => self.global.query_set_label(*id)); self.label("query set", &label); } } diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index a35fcacec..4fd284537 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -307,13 +307,23 @@ define_backend_caller! { gfx_if_empty, gfx_if_empty_hidden, "empty" if all( /// [`Id`]: id::Id #[macro_export] macro_rules! gfx_select { - ($id:expr => $global:ident.$method:ident( $($param:expr),* )) => { + // Simple two-component expression, like `self.0.method(..)`. + ($id:expr => $c0:ident.$c1:tt.$method:ident $params:tt) => { + $crate::gfx_select!($id => {$c0.$c1}, $method $params) + }; + + // Simple identifier-only expression, like `global.method(..)`. + ($id:expr => $c0:ident.$method:ident $params:tt) => { + $crate::gfx_select!($id => {$c0}, $method $params) + }; + + ($id:expr => {$($c:tt)*}, $method:ident $params:tt) => { match $id.backend() { - wgt::Backend::Vulkan => $crate::gfx_if_vulkan!($global.$method::<$crate::api::Vulkan>( $($param),* )), - wgt::Backend::Metal => $crate::gfx_if_metal!($global.$method::<$crate::api::Metal>( $($param),* )), - wgt::Backend::Dx12 => $crate::gfx_if_dx12!($global.$method::<$crate::api::Dx12>( $($param),* )), - wgt::Backend::Gl => $crate::gfx_if_gles!($global.$method::<$crate::api::Gles>( $($param),+ )), - wgt::Backend::Empty => $crate::gfx_if_empty!($global.$method::<$crate::api::Empty>( $($param),+ )), + wgt::Backend::Vulkan => $crate::gfx_if_vulkan!($($c)*.$method::<$crate::api::Vulkan> $params), + wgt::Backend::Metal => $crate::gfx_if_metal!($($c)*.$method::<$crate::api::Metal> $params), + wgt::Backend::Dx12 => $crate::gfx_if_dx12!($($c)*.$method::<$crate::api::Dx12> $params), + wgt::Backend::Gl => $crate::gfx_if_gles!($($c)*.$method::<$crate::api::Gles> $params), + wgt::Backend::Empty => $crate::gfx_if_empty!($($c)*.$method::<$crate::api::Empty> $params), other => panic!("Unexpected backend {:?}", other), } }; diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index c141eddb6..3d5fd1d14 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -107,9 +107,8 @@ impl ContextWgpuCore { desc: &crate::DeviceDescriptor<'_>, trace_dir: Option<&std::path::Path>, ) -> Result<(Device, Queue), crate::RequestDeviceError> { - let global = &self.0; let (device_id, queue_id, error) = unsafe { - global.create_device_from_hal( + self.0.create_device_from_hal( *adapter, hal_device, &desc.map_label(|l| l.map(Borrowed)), @@ -141,9 +140,10 @@ impl ContextWgpuCore { desc: &TextureDescriptor<'_>, ) -> Texture { let descriptor = desc.map_label_and_view_formats(|l| l.map(Borrowed), |v| v.to_vec()); - let global = &self.0; - let (id, error) = - unsafe { global.create_texture_from_hal::(hal_texture, device.id, &descriptor, ()) }; + let (id, error) = unsafe { + self.0 + .create_texture_from_hal::(hal_texture, device.id, &descriptor, ()) + }; if let Some(cause) = error { self.handle_error( &device.error_sink, @@ -165,9 +165,8 @@ impl ContextWgpuCore { device: &Device, desc: &BufferDescriptor<'_>, ) -> (wgc::id::BufferId, Buffer) { - let global = &self.0; let (id, error) = unsafe { - global.create_buffer_from_hal::( + self.0.create_buffer_from_hal::( hal_buffer, device.id, &desc.map_label(|l| l.map(Borrowed)), @@ -585,8 +584,7 @@ impl crate::Context for ContextWgpuCore { desc: &crate::DeviceDescriptor<'_>, trace_dir: Option<&std::path::Path>, ) -> Self::RequestDeviceFuture { - let global = &self.0; - let (device_id, queue_id, error) = wgc::gfx_select!(*adapter => global.adapter_request_device( + let (device_id, queue_id, error) = wgc::gfx_select!(*adapter => self.0.adapter_request_device( *adapter, &desc.map_label(|l| l.map(Borrowed)), trace_dir, @@ -610,8 +608,7 @@ impl crate::Context for ContextWgpuCore { } fn instance_poll_all_devices(&self, force_wait: bool) -> bool { - let global = &self.0; - match global.poll_all_devices(force_wait) { + match self.0.poll_all_devices(force_wait) { Ok(all_queue_empty) => all_queue_empty, Err(err) => self.handle_error_fatal(err, "Device::poll"), } @@ -624,8 +621,7 @@ impl crate::Context for ContextWgpuCore { surface: &Self::SurfaceId, _surface_data: &Self::SurfaceData, ) -> bool { - let global = &self.0; - match wgc::gfx_select!(adapter => global.adapter_is_surface_supported(*adapter, *surface)) { + match wgc::gfx_select!(adapter => self.0.adapter_is_surface_supported(*adapter, *surface)) { Ok(result) => result, Err(err) => self.handle_error_fatal(err, "Adapter::is_surface_supported"), } @@ -636,8 +632,7 @@ impl crate::Context for ContextWgpuCore { adapter: &Self::AdapterId, _adapter_data: &Self::AdapterData, ) -> Features { - let global = &self.0; - match wgc::gfx_select!(*adapter => global.adapter_features(*adapter)) { + match wgc::gfx_select!(*adapter => self.0.adapter_features(*adapter)) { Ok(features) => features, Err(err) => self.handle_error_fatal(err, "Adapter::features"), } @@ -648,8 +643,7 @@ impl crate::Context for ContextWgpuCore { adapter: &Self::AdapterId, _adapter_data: &Self::AdapterData, ) -> Limits { - let global = &self.0; - match wgc::gfx_select!(*adapter => global.adapter_limits(*adapter)) { + match wgc::gfx_select!(*adapter => self.0.adapter_limits(*adapter)) { Ok(limits) => limits, Err(err) => self.handle_error_fatal(err, "Adapter::limits"), } @@ -660,8 +654,7 @@ impl crate::Context for ContextWgpuCore { adapter: &Self::AdapterId, _adapter_data: &Self::AdapterData, ) -> DownlevelCapabilities { - let global = &self.0; - match wgc::gfx_select!(*adapter => global.adapter_downlevel_capabilities(*adapter)) { + match wgc::gfx_select!(*adapter => self.0.adapter_downlevel_capabilities(*adapter)) { Ok(downlevel) => downlevel, Err(err) => self.handle_error_fatal(err, "Adapter::downlevel_properties"), } @@ -672,8 +665,7 @@ impl crate::Context for ContextWgpuCore { adapter: &wgc::id::AdapterId, _adapter_data: &Self::AdapterData, ) -> AdapterInfo { - let global = &self.0; - match wgc::gfx_select!(*adapter => global.adapter_get_info(*adapter)) { + match wgc::gfx_select!(*adapter => self.0.adapter_get_info(*adapter)) { Ok(info) => info, Err(err) => self.handle_error_fatal(err, "Adapter::get_info"), } @@ -685,8 +677,7 @@ impl crate::Context for ContextWgpuCore { _adapter_data: &Self::AdapterData, format: wgt::TextureFormat, ) -> wgt::TextureFormatFeatures { - let global = &self.0; - match wgc::gfx_select!(*adapter => global.adapter_get_texture_format_features(*adapter, format)) + match wgc::gfx_select!(*adapter => self.0.adapter_get_texture_format_features(*adapter, format)) { Ok(info) => info, Err(err) => self.handle_error_fatal(err, "Adapter::get_texture_format_features"), @@ -698,8 +689,7 @@ impl crate::Context for ContextWgpuCore { adapter: &Self::AdapterId, _adapter_data: &Self::AdapterData, ) -> wgt::PresentationTimestamp { - let global = &self.0; - match wgc::gfx_select!(*adapter => global.adapter_get_presentation_timestamp(*adapter)) { + match wgc::gfx_select!(*adapter => self.0.adapter_get_presentation_timestamp(*adapter)) { Ok(timestamp) => timestamp, Err(err) => self.handle_error_fatal(err, "Adapter::correlate_presentation_timestamp"), } @@ -712,8 +702,7 @@ impl crate::Context for ContextWgpuCore { adapter: &Self::AdapterId, _adapter_data: &Self::AdapterData, ) -> wgt::SurfaceCapabilities { - let global = &self.0; - match wgc::gfx_select!(adapter => global.surface_get_capabilities(*surface, *adapter)) { + match wgc::gfx_select!(adapter => self.0.surface_get_capabilities(*surface, *adapter)) { Ok(caps) => caps, Err(wgc::instance::GetSurfaceSupportError::Unsupported) => { wgt::SurfaceCapabilities::default() @@ -730,8 +719,7 @@ impl crate::Context for ContextWgpuCore { _device_data: &Self::DeviceData, config: &crate::SurfaceConfiguration, ) { - let global = &self.0; - let error = wgc::gfx_select!(device => global.surface_configure(*surface, *device, config)); + let error = wgc::gfx_select!(device => self.0.surface_configure(*surface, *device, config)); if let Some(e) = error { self.handle_error_fatal(e, "Surface::configure"); } else { @@ -749,13 +737,12 @@ impl crate::Context for ContextWgpuCore { SurfaceStatus, Self::SurfaceOutputDetail, ) { - let global = &self.0; let device_id = surface_data .configured_device .lock() .expect("Surface was not configured?"); match wgc::gfx_select!( - device_id => global.surface_get_current_texture(*surface, ()) + device_id => self.0.surface_get_current_texture(*surface, ()) ) { Ok(wgc::present::SurfaceOutput { status, texture_id }) => { let (id, data) = { @@ -782,8 +769,7 @@ impl crate::Context for ContextWgpuCore { } fn surface_present(&self, texture: &Self::TextureId, detail: &Self::SurfaceOutputDetail) { - let global = &self.0; - match wgc::gfx_select!(texture => global.surface_present(detail.surface_id)) { + match wgc::gfx_select!(texture => self.0.surface_present(detail.surface_id)) { Ok(_status) => (), Err(err) => self.handle_error_fatal(err, "Surface::present"), } @@ -794,8 +780,7 @@ impl crate::Context for ContextWgpuCore { texture: &Self::TextureId, detail: &Self::SurfaceOutputDetail, ) { - let global = &self.0; - match wgc::gfx_select!(texture => global.surface_texture_discard(detail.surface_id)) { + match wgc::gfx_select!(texture => self.0.surface_texture_discard(detail.surface_id)) { Ok(_status) => (), Err(err) => self.handle_error_fatal(err, "Surface::discard_texture"), } @@ -806,16 +791,14 @@ impl crate::Context for ContextWgpuCore { device: &Self::DeviceId, _device_data: &Self::DeviceData, ) -> Features { - let global = &self.0; - match wgc::gfx_select!(device => global.device_features(*device)) { + match wgc::gfx_select!(device => self.0.device_features(*device)) { Ok(features) => features, Err(err) => self.handle_error_fatal(err, "Device::features"), } } fn device_limits(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) -> Limits { - let global = &self.0; - match wgc::gfx_select!(device => global.device_limits(*device)) { + match wgc::gfx_select!(device => self.0.device_limits(*device)) { Ok(limits) => limits, Err(err) => self.handle_error_fatal(err, "Device::limits"), } @@ -826,8 +809,7 @@ impl crate::Context for ContextWgpuCore { device: &Self::DeviceId, _device_data: &Self::DeviceData, ) -> DownlevelCapabilities { - let global = &self.0; - match wgc::gfx_select!(device => global.device_downlevel_properties(*device)) { + match wgc::gfx_select!(device => self.0.device_downlevel_properties(*device)) { Ok(limits) => limits, Err(err) => self.handle_error_fatal(err, "Device::downlevel_properties"), } @@ -849,7 +831,6 @@ impl crate::Context for ContextWgpuCore { desc: ShaderModuleDescriptor<'_>, shader_bound_checks: wgt::ShaderBoundChecks, ) -> (Self::ShaderModuleId, Self::ShaderModuleData) { - let global = &self.0; let descriptor = wgc::pipeline::ShaderModuleDescriptor { label: desc.label.map(Borrowed), shader_bound_checks, @@ -890,7 +871,7 @@ impl crate::Context for ContextWgpuCore { ShaderSource::Dummy(_) => panic!("found `ShaderSource::Dummy`"), }; let (id, error) = wgc::gfx_select!( - device => global.device_create_shader_module(*device, &descriptor, source, ()) + device => self.0.device_create_shader_module(*device, &descriptor, source, ()) ); if let Some(cause) = error { self.handle_error( @@ -910,7 +891,6 @@ impl crate::Context for ContextWgpuCore { device_data: &Self::DeviceData, desc: &ShaderModuleDescriptorSpirV<'_>, ) -> (Self::ShaderModuleId, Self::ShaderModuleData) { - let global = &self.0; let descriptor = wgc::pipeline::ShaderModuleDescriptor { label: desc.label.map(Borrowed), // Doesn't matter the value since spirv shaders aren't mutated to include @@ -918,7 +898,7 @@ impl crate::Context for ContextWgpuCore { shader_bound_checks: unsafe { wgt::ShaderBoundChecks::unchecked() }, }; let (id, error) = wgc::gfx_select!( - device => global.device_create_shader_module_spirv(*device, &descriptor, Borrowed(&desc.source), ()) + device => self.0.device_create_shader_module_spirv(*device, &descriptor, Borrowed(&desc.source), ()) ); if let Some(cause) = error { self.handle_error( @@ -938,13 +918,12 @@ impl crate::Context for ContextWgpuCore { device_data: &Self::DeviceData, desc: &BindGroupLayoutDescriptor<'_>, ) -> (Self::BindGroupLayoutId, Self::BindGroupLayoutData) { - let global = &self.0; let descriptor = wgc::binding_model::BindGroupLayoutDescriptor { label: desc.label.map(Borrowed), entries: Borrowed(desc.entries), }; let (id, error) = wgc::gfx_select!( - device => global.device_create_bind_group_layout(*device, &descriptor, ()) + device => self.0.device_create_bind_group_layout(*device, &descriptor, ()) ); if let Some(cause) = error { self.handle_error( @@ -1055,8 +1034,7 @@ impl crate::Context for ContextWgpuCore { entries: Borrowed(&entries), }; - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_bind_group( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_bind_group( *device, &descriptor, () @@ -1098,8 +1076,7 @@ impl crate::Context for ContextWgpuCore { push_constant_ranges: Borrowed(desc.push_constant_ranges), }; - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_pipeline_layout( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_pipeline_layout( *device, &descriptor, () @@ -1164,8 +1141,7 @@ impl crate::Context for ContextWgpuCore { multiview: desc.multiview, }; - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_render_pipeline( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_render_pipeline( *device, &descriptor, (), @@ -1210,8 +1186,7 @@ impl crate::Context for ContextWgpuCore { }, }; - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_compute_pipeline( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_compute_pipeline( *device, &descriptor, (), @@ -1242,8 +1217,7 @@ impl crate::Context for ContextWgpuCore { device_data: &Self::DeviceData, desc: &crate::BufferDescriptor<'_>, ) -> (Self::BufferId, Self::BufferData) { - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_buffer( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_buffer( *device, &desc.map_label(|l| l.map(Borrowed)), () @@ -1271,8 +1245,7 @@ impl crate::Context for ContextWgpuCore { desc: &TextureDescriptor<'_>, ) -> (Self::TextureId, Self::TextureData) { let wgt_desc = desc.map_label_and_view_formats(|l| l.map(Borrowed), |v| v.to_vec()); - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_texture( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_texture( *device, &wgt_desc, () @@ -1317,8 +1290,7 @@ impl crate::Context for ContextWgpuCore { border_color: desc.border_color, }; - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_sampler( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_sampler( *device, &descriptor, () @@ -1340,8 +1312,7 @@ impl crate::Context for ContextWgpuCore { device_data: &Self::DeviceData, desc: &wgt::QuerySetDescriptor>, ) -> (Self::QuerySetId, Self::QuerySetData) { - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_query_set( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_query_set( *device, &desc.map_label(|l| l.map(Borrowed)), () @@ -1357,8 +1328,7 @@ impl crate::Context for ContextWgpuCore { device_data: &Self::DeviceData, desc: &CommandEncoderDescriptor<'_>, ) -> (Self::CommandEncoderId, Self::CommandEncoderData) { - let global = &self.0; - let (id, error) = wgc::gfx_select!(device => global.device_create_command_encoder( + let (id, error) = wgc::gfx_select!(device => self.0.device_create_command_encoder( *device, &desc.map_label(|l| l.map(Borrowed)), () @@ -1402,18 +1372,16 @@ impl crate::Context for ContextWgpuCore { fn device_drop(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) { #[cfg(any(native, Emscripten))] { - let global = &self.0; - match wgc::gfx_select!(device => global.device_poll(*device, wgt::Maintain::wait())) { + match wgc::gfx_select!(device => self.0.device_poll(*device, wgt::Maintain::wait())) { Ok(_) => {} Err(err) => self.handle_error_fatal(err, "Device::drop"), } - wgc::gfx_select!(device => global.device_drop(*device)); + wgc::gfx_select!(device => self.0.device_drop(*device)); } } #[cfg_attr(target_arch = "wasm32", allow(unused))] fn queue_drop(&self, queue: &Self::QueueId, _device_data: &Self::QueueData) { - let global = &self.0; - wgc::gfx_select!(queue => global.queue_drop(*queue)); + wgc::gfx_select!(queue => self.0.queue_drop(*queue)); } fn device_set_device_lost_callback( &self, @@ -1421,13 +1389,11 @@ impl crate::Context for ContextWgpuCore { _device_data: &Self::DeviceData, device_lost_callback: crate::context::DeviceLostCallback, ) { - let global = &self.0; let device_lost_closure = DeviceLostClosure::from_rust(device_lost_callback); - wgc::gfx_select!(device => global.device_set_device_lost_closure(*device, device_lost_closure)); + wgc::gfx_select!(device => self.0.device_set_device_lost_closure(*device, device_lost_closure)); } fn device_destroy(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) { - let global = &self.0; - wgc::gfx_select!(device => global.device_destroy(*device)); + wgc::gfx_select!(device => self.0.device_destroy(*device)); } fn device_mark_lost( &self, @@ -1437,8 +1403,7 @@ impl crate::Context for ContextWgpuCore { ) { // We do not provide a reason to device_lose, because all reasons other than // destroyed (which this is not) are "unknown". - let global = &self.0; - wgc::gfx_select!(device => global.device_mark_lost(*device, message)); + wgc::gfx_select!(device => self.0.device_mark_lost(*device, message)); } fn device_poll( &self, @@ -1446,9 +1411,8 @@ impl crate::Context for ContextWgpuCore { _device_data: &Self::DeviceData, maintain: crate::Maintain, ) -> wgt::MaintainResult { - let global = &self.0; let maintain_inner = maintain.map_index(|i| *i.1.as_ref().downcast_ref().unwrap()); - match wgc::gfx_select!(device => global.device_poll( + match wgc::gfx_select!(device => self.0.device_poll( *device, maintain_inner )) { @@ -1511,8 +1475,7 @@ impl crate::Context for ContextWgpuCore { ))), }; - let global = &self.0; - match wgc::gfx_select!(buffer => global.buffer_map_async(*buffer, range, operation)) { + match wgc::gfx_select!(buffer => self.0.buffer_map_async(*buffer, range, operation)) { Ok(()) => (), Err(cause) => { self.handle_error_nolabel(&buffer_data.error_sink, cause, "Buffer::map_async") @@ -1526,8 +1489,7 @@ impl crate::Context for ContextWgpuCore { sub_range: Range, ) -> Box { let size = sub_range.end - sub_range.start; - let global = &self.0; - match wgc::gfx_select!(buffer => global.buffer_get_mapped_range( + match wgc::gfx_select!(buffer => self.0.buffer_get_mapped_range( *buffer, sub_range.start, Some(size) @@ -1541,8 +1503,7 @@ impl crate::Context for ContextWgpuCore { } fn buffer_unmap(&self, buffer: &Self::BufferId, buffer_data: &Self::BufferData) { - let global = &self.0; - match wgc::gfx_select!(buffer => global.buffer_unmap(*buffer)) { + match wgc::gfx_select!(buffer => self.0.buffer_unmap(*buffer)) { Ok(()) => (), Err(cause) => { self.handle_error_nolabel(&buffer_data.error_sink, cause, "Buffer::buffer_unmap") @@ -1568,9 +1529,8 @@ impl crate::Context for ContextWgpuCore { array_layer_count: desc.array_layer_count, }, }; - let global = &self.0; let (id, error) = wgc::gfx_select!( - texture => global.texture_create_view(*texture, &descriptor, ()) + texture => self.0.texture_create_view(*texture, &descriptor, ()) ); if let Some(cause) = error { self.handle_error( @@ -1589,30 +1549,25 @@ impl crate::Context for ContextWgpuCore { } fn adapter_drop(&self, adapter: &Self::AdapterId, _adapter_data: &Self::AdapterData) { - let global = &self.0; - wgc::gfx_select!(*adapter => global.adapter_drop(*adapter)) + wgc::gfx_select!(*adapter => self.0.adapter_drop(*adapter)) } fn buffer_destroy(&self, buffer: &Self::BufferId, _buffer_data: &Self::BufferData) { // Per spec, no error to report. Even calling destroy multiple times is valid. - let global = &self.0; - let _ = wgc::gfx_select!(buffer => global.buffer_destroy(*buffer)); + let _ = wgc::gfx_select!(buffer => self.0.buffer_destroy(*buffer)); } fn buffer_drop(&self, buffer: &Self::BufferId, _buffer_data: &Self::BufferData) { - let global = &self.0; - wgc::gfx_select!(buffer => global.buffer_drop(*buffer, false)) + wgc::gfx_select!(buffer => self.0.buffer_drop(*buffer, false)) } fn texture_destroy(&self, texture: &Self::TextureId, _texture_data: &Self::TextureData) { // Per spec, no error to report. Even calling destroy multiple times is valid. - let global = &self.0; - let _ = wgc::gfx_select!(texture => global.texture_destroy(*texture)); + let _ = wgc::gfx_select!(texture => self.0.texture_destroy(*texture)); } fn texture_drop(&self, texture: &Self::TextureId, _texture_data: &Self::TextureData) { - let global = &self.0; - wgc::gfx_select!(texture => global.texture_drop(*texture, false)) + wgc::gfx_select!(texture => self.0.texture_drop(*texture, false)) } fn texture_view_drop( @@ -1620,18 +1575,15 @@ impl crate::Context for ContextWgpuCore { texture_view: &Self::TextureViewId, __texture_view_data: &Self::TextureViewData, ) { - let global = &self.0; - let _ = wgc::gfx_select!(*texture_view => global.texture_view_drop(*texture_view, false)); + let _ = wgc::gfx_select!(*texture_view => self.0.texture_view_drop(*texture_view, false)); } fn sampler_drop(&self, sampler: &Self::SamplerId, _sampler_data: &Self::SamplerData) { - let global = &self.0; - wgc::gfx_select!(*sampler => global.sampler_drop(*sampler)) + wgc::gfx_select!(*sampler => self.0.sampler_drop(*sampler)) } fn query_set_drop(&self, query_set: &Self::QuerySetId, _query_set_data: &Self::QuerySetData) { - let global = &self.0; - wgc::gfx_select!(*query_set => global.query_set_drop(*query_set)) + wgc::gfx_select!(*query_set => self.0.query_set_drop(*query_set)) } fn bind_group_drop( @@ -1639,8 +1591,7 @@ impl crate::Context for ContextWgpuCore { bind_group: &Self::BindGroupId, _bind_group_data: &Self::BindGroupData, ) { - let global = &self.0; - wgc::gfx_select!(*bind_group => global.bind_group_drop(*bind_group)) + wgc::gfx_select!(*bind_group => self.0.bind_group_drop(*bind_group)) } fn bind_group_layout_drop( @@ -1648,8 +1599,7 @@ impl crate::Context for ContextWgpuCore { bind_group_layout: &Self::BindGroupLayoutId, _bind_group_layout_data: &Self::BindGroupLayoutData, ) { - let global = &self.0; - wgc::gfx_select!(*bind_group_layout => global.bind_group_layout_drop(*bind_group_layout)) + wgc::gfx_select!(*bind_group_layout => self.0.bind_group_layout_drop(*bind_group_layout)) } fn pipeline_layout_drop( @@ -1657,16 +1607,14 @@ impl crate::Context for ContextWgpuCore { pipeline_layout: &Self::PipelineLayoutId, _pipeline_layout_data: &Self::PipelineLayoutData, ) { - let global = &self.0; - wgc::gfx_select!(*pipeline_layout => global.pipeline_layout_drop(*pipeline_layout)) + wgc::gfx_select!(*pipeline_layout => self.0.pipeline_layout_drop(*pipeline_layout)) } fn shader_module_drop( &self, shader_module: &Self::ShaderModuleId, _shader_module_data: &Self::ShaderModuleData, ) { - let global = &self.0; - wgc::gfx_select!(*shader_module => global.shader_module_drop(*shader_module)) + wgc::gfx_select!(*shader_module => self.0.shader_module_drop(*shader_module)) } fn command_encoder_drop( &self, @@ -1674,8 +1622,7 @@ impl crate::Context for ContextWgpuCore { command_encoder_data: &Self::CommandEncoderData, ) { if command_encoder_data.open { - let global = &self.0; - wgc::gfx_select!(command_encoder => global.command_encoder_drop(*command_encoder)) + wgc::gfx_select!(command_encoder => self.0.command_encoder_drop(*command_encoder)) } } @@ -1684,8 +1631,7 @@ impl crate::Context for ContextWgpuCore { command_buffer: &Self::CommandBufferId, _command_buffer_data: &Self::CommandBufferData, ) { - let global = &self.0; - wgc::gfx_select!(*command_buffer => global.command_buffer_drop(*command_buffer)) + wgc::gfx_select!(*command_buffer => self.0.command_buffer_drop(*command_buffer)) } fn render_bundle_drop( @@ -1693,8 +1639,7 @@ impl crate::Context for ContextWgpuCore { render_bundle: &Self::RenderBundleId, _render_bundle_data: &Self::RenderBundleData, ) { - let global = &self.0; - wgc::gfx_select!(*render_bundle => global.render_bundle_drop(*render_bundle)) + wgc::gfx_select!(*render_bundle => self.0.render_bundle_drop(*render_bundle)) } fn compute_pipeline_drop( @@ -1702,8 +1647,7 @@ impl crate::Context for ContextWgpuCore { pipeline: &Self::ComputePipelineId, _pipeline_data: &Self::ComputePipelineData, ) { - let global = &self.0; - wgc::gfx_select!(*pipeline => global.compute_pipeline_drop(*pipeline)) + wgc::gfx_select!(*pipeline => self.0.compute_pipeline_drop(*pipeline)) } fn render_pipeline_drop( @@ -1711,8 +1655,7 @@ impl crate::Context for ContextWgpuCore { pipeline: &Self::RenderPipelineId, _pipeline_data: &Self::RenderPipelineData, ) { - let global = &self.0; - wgc::gfx_select!(*pipeline => global.render_pipeline_drop(*pipeline)) + wgc::gfx_select!(*pipeline => self.0.render_pipeline_drop(*pipeline)) } fn compute_pipeline_get_bind_group_layout( @@ -1721,8 +1664,7 @@ impl crate::Context for ContextWgpuCore { _pipeline_data: &Self::ComputePipelineData, index: u32, ) -> (Self::BindGroupLayoutId, Self::BindGroupLayoutData) { - let global = &self.0; - let (id, error) = wgc::gfx_select!(*pipeline => global.compute_pipeline_get_bind_group_layout(*pipeline, index, ())); + let (id, error) = wgc::gfx_select!(*pipeline => self.0.compute_pipeline_get_bind_group_layout(*pipeline, index, ())); if let Some(err) = error { panic!("Error reflecting bind group {index}: {err}"); } @@ -1735,8 +1677,7 @@ impl crate::Context for ContextWgpuCore { _pipeline_data: &Self::RenderPipelineData, index: u32, ) -> (Self::BindGroupLayoutId, Self::BindGroupLayoutData) { - let global = &self.0; - let (id, error) = wgc::gfx_select!(*pipeline => global.render_pipeline_get_bind_group_layout(*pipeline, index, ())); + let (id, error) = wgc::gfx_select!(*pipeline => self.0.render_pipeline_get_bind_group_layout(*pipeline, index, ())); if let Some(err) = error { panic!("Error reflecting bind group {index}: {err}"); } @@ -1755,8 +1696,7 @@ impl crate::Context for ContextWgpuCore { destination_offset: wgt::BufferAddress, copy_size: wgt::BufferAddress, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_copy_buffer_to_buffer( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_copy_buffer_to_buffer( *encoder, *source, source_offset, @@ -1780,8 +1720,7 @@ impl crate::Context for ContextWgpuCore { destination: crate::ImageCopyTexture<'_>, copy_size: wgt::Extent3d, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_copy_buffer_to_texture( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_copy_buffer_to_texture( *encoder, &map_buffer_copy_view(source), &map_texture_copy_view(destination), @@ -1803,8 +1742,7 @@ impl crate::Context for ContextWgpuCore { destination: crate::ImageCopyBuffer<'_>, copy_size: wgt::Extent3d, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_copy_texture_to_buffer( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_copy_texture_to_buffer( *encoder, &map_texture_copy_view(source), &map_buffer_copy_view(destination), @@ -1826,8 +1764,7 @@ impl crate::Context for ContextWgpuCore { destination: crate::ImageCopyTexture<'_>, copy_size: wgt::Extent3d, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_copy_texture_to_texture( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_copy_texture_to_texture( *encoder, &map_texture_copy_view(source), &map_texture_copy_view(destination), @@ -1874,11 +1811,10 @@ impl crate::Context for ContextWgpuCore { _pass: &mut Self::ComputePassId, pass_data: &mut Self::ComputePassData, ) { - let global = &self.0; if let Err(cause) = wgc::gfx_select!( - encoder => global.command_encoder_run_compute_pass(*encoder, pass_data) + encoder => self.0.command_encoder_run_compute_pass(*encoder, pass_data) ) { - let name = wgc::gfx_select!(encoder => global.command_buffer_label(*encoder)); + let name = wgc::gfx_select!(encoder => self.0.command_buffer_label(*encoder)); self.handle_error( &encoder_data.error_sink, cause, @@ -1958,11 +1894,10 @@ impl crate::Context for ContextWgpuCore { _pass: &mut Self::RenderPassId, pass_data: &mut Self::RenderPassData, ) { - let global = &self.0; if let Err(cause) = - wgc::gfx_select!(encoder => global.command_encoder_run_render_pass(*encoder, pass_data)) + wgc::gfx_select!(encoder => self.0.command_encoder_run_render_pass(*encoder, pass_data)) { - let name = wgc::gfx_select!(encoder => global.command_buffer_label(*encoder)); + let name = wgc::gfx_select!(encoder => self.0.command_buffer_label(*encoder)); self.handle_error( &encoder_data.error_sink, cause, @@ -1980,9 +1915,8 @@ impl crate::Context for ContextWgpuCore { ) -> (Self::CommandBufferId, Self::CommandBufferData) { let descriptor = wgt::CommandBufferDescriptor::default(); encoder_data.open = false; // prevent the drop - let global = &self.0; let (id, error) = - wgc::gfx_select!(encoder => global.command_encoder_finish(encoder, &descriptor)); + wgc::gfx_select!(encoder => self.0.command_encoder_finish(encoder, &descriptor)); if let Some(cause) = error { self.handle_error_nolabel(&encoder_data.error_sink, cause, "a CommandEncoder"); } @@ -1996,8 +1930,7 @@ impl crate::Context for ContextWgpuCore { texture: &crate::Texture, subresource_range: &wgt::ImageSubresourceRange, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_clear_texture( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_clear_texture( *encoder, texture.id.into(), subresource_range @@ -2018,8 +1951,7 @@ impl crate::Context for ContextWgpuCore { offset: wgt::BufferAddress, size: Option, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_clear_buffer( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_clear_buffer( *encoder, buffer.id.into(), offset, size @@ -2038,9 +1970,8 @@ impl crate::Context for ContextWgpuCore { encoder_data: &Self::CommandEncoderData, label: &str, ) { - let global = &self.0; if let Err(cause) = - wgc::gfx_select!(encoder => global.command_encoder_insert_debug_marker(*encoder, label)) + wgc::gfx_select!(encoder => self.0.command_encoder_insert_debug_marker(*encoder, label)) { self.handle_error_nolabel( &encoder_data.error_sink, @@ -2056,9 +1987,8 @@ impl crate::Context for ContextWgpuCore { encoder_data: &Self::CommandEncoderData, label: &str, ) { - let global = &self.0; if let Err(cause) = - wgc::gfx_select!(encoder => global.command_encoder_push_debug_group(*encoder, label)) + wgc::gfx_select!(encoder => self.0.command_encoder_push_debug_group(*encoder, label)) { self.handle_error_nolabel( &encoder_data.error_sink, @@ -2073,9 +2003,8 @@ impl crate::Context for ContextWgpuCore { encoder: &Self::CommandEncoderId, encoder_data: &Self::CommandEncoderData, ) { - let global = &self.0; if let Err(cause) = - wgc::gfx_select!(encoder => global.command_encoder_pop_debug_group(*encoder)) + wgc::gfx_select!(encoder => self.0.command_encoder_pop_debug_group(*encoder)) { self.handle_error_nolabel( &encoder_data.error_sink, @@ -2093,8 +2022,7 @@ impl crate::Context for ContextWgpuCore { _query_set_data: &Self::QuerySetData, query_index: u32, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_write_timestamp( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_write_timestamp( *encoder, *query_set, query_index @@ -2119,8 +2047,7 @@ impl crate::Context for ContextWgpuCore { _destination_data: &Self::BufferData, destination_offset: wgt::BufferAddress, ) { - let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder => global.command_encoder_resolve_query_set( + if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_resolve_query_set( *encoder, *query_set, first_query, @@ -2142,8 +2069,7 @@ impl crate::Context for ContextWgpuCore { encoder_data: Self::RenderBundleEncoderData, desc: &crate::RenderBundleDescriptor<'_>, ) -> (Self::RenderBundleId, Self::RenderBundleData) { - let global = &self.0; - let (id, error) = wgc::gfx_select!(encoder_data.parent() => global.render_bundle_encoder_finish( + let (id, error) = wgc::gfx_select!(encoder_data.parent() => self.0.render_bundle_encoder_finish( encoder_data, &desc.map_label(|l| l.map(Borrowed)), () @@ -2163,9 +2089,8 @@ impl crate::Context for ContextWgpuCore { offset: wgt::BufferAddress, data: &[u8], ) { - let global = &self.0; match wgc::gfx_select!( - *queue => global.queue_write_buffer(*queue, *buffer, offset, data) + *queue => self.0.queue_write_buffer(*queue, *buffer, offset, data) ) { Ok(()) => (), Err(err) => { @@ -2183,9 +2108,8 @@ impl crate::Context for ContextWgpuCore { offset: wgt::BufferAddress, size: wgt::BufferSize, ) -> Option<()> { - let global = &self.0; match wgc::gfx_select!( - *queue => global.queue_validate_write_buffer(*queue, *buffer, offset, size.get()) + *queue => self.0.queue_validate_write_buffer(*queue, *buffer, offset, size.get()) ) { Ok(()) => Some(()), Err(err) => { @@ -2201,9 +2125,8 @@ impl crate::Context for ContextWgpuCore { queue_data: &Self::QueueData, size: wgt::BufferSize, ) -> Option> { - let global = &self.0; match wgc::gfx_select!( - *queue => global.queue_create_staging_buffer(*queue, size, ()) + *queue => self.0.queue_create_staging_buffer(*queue, size, ()) ) { Ok((buffer_id, ptr)) => Some(Box::new(QueueWriteBuffer { buffer_id, @@ -2228,13 +2151,12 @@ impl crate::Context for ContextWgpuCore { offset: wgt::BufferAddress, staging_buffer: &dyn crate::context::QueueWriteBuffer, ) { - let global = &self.0; let staging_buffer = staging_buffer .as_any() .downcast_ref::() .unwrap(); match wgc::gfx_select!( - *queue => global.queue_write_staging_buffer(*queue, *buffer, offset, staging_buffer.buffer_id) + *queue => self.0.queue_write_staging_buffer(*queue, *buffer, offset, staging_buffer.buffer_id) ) { Ok(()) => (), Err(err) => { @@ -2252,8 +2174,7 @@ impl crate::Context for ContextWgpuCore { data_layout: wgt::ImageDataLayout, size: wgt::Extent3d, ) { - let global = &self.0; - match wgc::gfx_select!(*queue => global.queue_write_texture( + match wgc::gfx_select!(*queue => self.0.queue_write_texture( *queue, &map_texture_copy_view(texture), data, @@ -2276,8 +2197,7 @@ impl crate::Context for ContextWgpuCore { dest: crate::ImageCopyTextureTagged<'_>, size: wgt::Extent3d, ) { - let global = &self.0; - match wgc::gfx_select!(*queue => global.queue_copy_external_image_to_texture( + match wgc::gfx_select!(*queue => self.0.queue_copy_external_image_to_texture( *queue, source, map_texture_tagged_copy_view(dest), @@ -2302,8 +2222,7 @@ impl crate::Context for ContextWgpuCore { .map(|(i, _)| i) .collect::>(); - let global = &self.0; - let index = match wgc::gfx_select!(*queue => global.queue_submit(*queue, &temp_command_buffers)) + let index = match wgc::gfx_select!(*queue => self.0.queue_submit(*queue, &temp_command_buffers)) { Ok(index) => index, Err(err) => self.handle_error_fatal(err, "Queue::submit"), @@ -2317,8 +2236,7 @@ impl crate::Context for ContextWgpuCore { queue: &Self::QueueId, _queue_data: &Self::QueueData, ) -> f32 { - let global = &self.0; - let res = wgc::gfx_select!(queue => global.queue_get_timestamp_period( + let res = wgc::gfx_select!(queue => self.0.queue_get_timestamp_period( *queue )); match res { @@ -2337,21 +2255,18 @@ impl crate::Context for ContextWgpuCore { ) { let closure = wgc::device::queue::SubmittedWorkDoneClosure::from_rust(callback); - let global = &self.0; - let res = wgc::gfx_select!(queue => global.queue_on_submitted_work_done(*queue, closure)); + let res = wgc::gfx_select!(queue => self.0.queue_on_submitted_work_done(*queue, closure)); if let Err(cause) = res { self.handle_error_fatal(cause, "Queue::on_submitted_work_done"); } } fn device_start_capture(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) { - let global = &self.0; - wgc::gfx_select!(device => global.device_start_capture(*device)); + wgc::gfx_select!(device => self.0.device_start_capture(*device)); } fn device_stop_capture(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) { - let global = &self.0; - wgc::gfx_select!(device => global.device_stop_capture(*device)); + wgc::gfx_select!(device => self.0.device_stop_capture(*device)); } fn compute_pass_set_pipeline(