From 443fca8097ecad6be1139f20ea3cdc6159572289 Mon Sep 17 00:00:00 2001 From: Sam <16504129+sagudev@users.noreply.github.com> Date: Mon, 31 Aug 2026 20:21:46 +0200 Subject: [PATCH] Move erroring from create_bind_group_layout into wgc (#10215) Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- cts_runner/test.lst | 1 + deno_webgpu/device.rs | 8 ++++---- player/src/lib.rs | 2 +- wgpu-core-remote/src/global/device.rs | 9 ++------- wgpu-core/src/device/resource.rs | 22 +++++++++++++--------- wgpu/src/backend/wgpu_core.rs | 7 +------ 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/cts_runner/test.lst b/cts_runner/test.lst index a60289903..cd01af983 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -75,6 +75,7 @@ webgpu:api,validation,buffer,destroy:* webgpu:api,validation,capability_checks,features,clip_distances:* webgpu:api,validation,capability_checks,features,texture_component_swizzle:* webgpu:api,validation,capability_checks,features,texture_formats:render_bundle_encoder_descriptor_depth_stencil_format:* +webgpu:api,validation,capability_checks,features,texture_formats:storage_texture_binding_layout:* webgpu:api,validation,capability_checks,features,texture_formats:texture_descriptor_view_formats:* webgpu:api,validation,capability_checks,features,texture_formats:texture_descriptor:* webgpu:api,validation,capability_checks,features,texture_formats:texture_view_descriptor:* diff --git a/deno_webgpu/device.rs b/deno_webgpu/device.rs index fe7123da2..45a629e2e 100644 --- a/deno_webgpu/device.rs +++ b/deno_webgpu/device.rs @@ -332,9 +332,11 @@ impl GPUDevice { multisampled: texture.multisampled, } } else if let Some(storage_texture) = entry.storage_texture { + let format = storage_texture.format.into(); + self.validate_texture_format_required_feature(format)?; BindingType::StorageTexture { access: storage_texture.access.into(), - format: storage_texture.format.into(), + format, view_dimension: storage_texture.view_dimension.into(), } } else if entry.external_texture.is_some() { @@ -356,11 +358,9 @@ impl GPUDevice { entries: Cow::Owned(entries), }; - let (wgpu_bind_group_layout, err) = + let wgpu_bind_group_layout = self.wgpu_device.create_bind_group_layout(&wgpu_descriptor); - self.error_handler.push_error(err); - Ok(GPUBindGroupLayout { wgpu_bind_group_layout, label: descriptor.label, diff --git a/player/src/lib.rs b/player/src/lib.rs index b4b6adce9..23d0f0bba 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -186,7 +186,7 @@ impl Player { unimplemented!() } Action::CreateBindGroupLayout(id, desc) => { - let (bind_group_layout, _error) = device.create_bind_group_layout(&desc); + let bind_group_layout = device.create_bind_group_layout(&desc); self.bind_group_layouts.insert(id, bind_group_layout); } Action::GetRenderPipelineBindGroupLayout { diff --git a/wgpu-core-remote/src/global/device.rs b/wgpu-core-remote/src/global/device.rs index 63fba911d..7b4946676 100644 --- a/wgpu-core-remote/src/global/device.rs +++ b/wgpu-core-remote/src/global/device.rs @@ -453,9 +453,6 @@ impl Global { device_id: DeviceId, desc: &BindGroupLayoutDescriptor, id_in: id::BindGroupLayoutId, - ) -> ( - id::BindGroupLayoutId, - Option, ) { let mut hub = self.hub.borrow_mut(); let Hub { @@ -471,11 +468,9 @@ impl Global { entries: Cow::Borrowed(&desc.entries), }; - let (bgl, error) = device.create_bind_group_layout(&desc); + let bgl = device.create_bind_group_layout(&desc); - let id = bind_group_layouts.assign(id_in, bgl); - - (id, error) + bind_group_layouts.assign(id_in, bgl); } pub fn bind_group_layout_remove( diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 221c9f152..95f9f8196 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -2920,16 +2920,20 @@ impl Device { pub fn create_bind_group_layout( self: &Arc, desc: &binding_model::BindGroupLayoutDescriptor, - ) -> (Arc, Option) { + ) -> Arc { profiling::scope!("Device::create_bind_group_layout"); - let (bgl, error) = match self.create_bind_group_layout_inner(desc) { - Ok(layout) => (layout, None), - Err(e) => ( - BindGroupLayout::invalid(self, desc.label.to_string()), - Some(e), - ), - }; + let bgl = self + .create_bind_group_layout_inner(desc) + .unwrap_or_else(|err| { + self.handle_error( + err, + desc.label.as_deref(), + "Device::create_bind_group_layout", + ); + BindGroupLayout::invalid(self, desc.label.to_string()) + }); + #[cfg(feature = "trace")] if let Some(ref mut trace) = *self.trace.lock() { use crate::device::trace::IntoTrace; @@ -2943,7 +2947,7 @@ impl Device { "Device::create_bind_group_layout -> {:?}", Arc::as_ptr(&bgl) ); - (bgl, error) + bgl } fn create_bind_group_layout_inner( diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 9d2c555f3..de6bd5657 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -883,12 +883,7 @@ impl dispatch::DeviceInterface for CoreDevice { label: desc.label.map(Borrowed), entries: Borrowed(desc.entries), }; - let (wgpu_bind_group_layout, error) = - self.wgpu_device.create_bind_group_layout(&descriptor); - if let Some(cause) = error { - self.wgpu_device - .handle_error(cause, desc.label, "Device::create_bind_group_layout"); - } + let wgpu_bind_group_layout = self.wgpu_device.create_bind_group_layout(&descriptor); CoreBindGroupLayout { wgpu_bind_group_layout, }