From 124f4a89f6fa9ab3e0a5548c70bf70e94577002f Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Wed, 3 Dec 2025 13:39:57 -0500 Subject: [PATCH] feat(core): add `Global::create_bind_group_layout_error` --- CHANGELOG.md | 1 + wgpu-core/src/device/global.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dcf7e6de83..c301eab63ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -181,6 +181,7 @@ By @cwfitzgerald in [#8609](https://github.com/gfx-rs/wgpu/pull/8609). - Added support for binding arrays of storage textures on Metal. By @msvbg in [#8464](https://github.com/gfx-rs/wgpu/pull/8464) - Added support for multisampled texture arrays on Vulkan through adapter feature `MULTISAMPLE_ARRAY`. By @LaylBongers in [#8571](https://github.com/gfx-rs/wgpu/pull/8571). - Added `get_configuration` to `wgpu::Surface`, that returns the current configuration of `wgpu::Surface`. By @sagudev in [#8664](https://github.com/gfx-rs/wgpu/pull/8664). +- Add `wgpu_core::Global::create_bind_group_layout_error`. By @ErichDonGubler in [#8650](https://github.com/gfx-rs/wgpu/pull/8650). ### Changes diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index c58f9023300..4588e84abda 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -215,6 +215,23 @@ impl Global { fid.assign(Fallible::Invalid(Arc::new(desc.label.to_string()))); } + /// Assign `id_in` an error with the given `label`. + /// + /// In JavaScript environments, it is possible to call `GPUDevice.createBindGroupLayout` with + /// entries that are invalid. Because our Rust's types for bind group layouts prevent even + /// calling [`Self::device_create_bind_group`], we let standards-compliant environments + /// register an invalid bind group layout so this crate's API can still be consistently used. + /// + /// See [`Self::create_buffer_error`] for additional context and explanation. + pub fn create_bind_group_layout_error( + &self, + id_in: Option, + label: Option>, + ) { + let fid = self.hub.bind_group_layouts.prepare(id_in); + fid.assign(Fallible::Invalid(Arc::new(label.to_string()))); + } + pub fn buffer_destroy(&self, buffer_id: id::BufferId) { profiling::scope!("Buffer::destroy"); api_log!("Buffer::destroy {buffer_id:?}");