From 0584f1eb38f892de77ac59a41fef63b91372ed39 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Sat, 12 Sep 2026 10:30:00 +0200 Subject: [PATCH] [remote-types] vendor `BindGroupLayoutEntry` and use `ShaderStagesWebGPU` in it Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core-remote-types/src/binding_model.rs | 17 +++++++++++++++- wgpu-core-remote/src/global/device.rs | 22 ++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/wgpu-core-remote-types/src/binding_model.rs b/wgpu-core-remote-types/src/binding_model.rs index 76ae3c465..a9a0238a6 100644 --- a/wgpu-core-remote-types/src/binding_model.rs +++ b/wgpu-core-remote-types/src/binding_model.rs @@ -67,6 +67,21 @@ pub struct BindGroupDescriptor<'a> { pub entries: Cow<'a, [BindGroupEntry]>, } +/// Describes a single binding inside a bind group. +/// +/// Corresponds to [WebGPU `GPUBindGroupLayoutEntry`]( +/// https://gpuweb.github.io/gpuweb/#dictdef-gpubindgrouplayoutentry). +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct BindGroupLayoutEntry { + /// Binding index. Must match shader index and be unique inside a `BindGroupLayout`. A binding + /// of index 1, would be described as `@group(0) @binding(1)` in shaders. + pub binding: u32, + /// Which shader stages can see this binding. + pub visibility: wgt::ShaderStagesWebGPU, + /// The type of the binding + pub ty: wgt::BindingType, +} + /// Corresponds to [`GPUBindGroupLayoutDescriptor`](https://www.w3.org/TR/webgpu/#dictdef-gpubindgrouplayoutdescriptor). #[derive(Clone, Debug, Serialize, Deserialize)] pub struct BindGroupLayoutDescriptor<'a> { @@ -75,5 +90,5 @@ pub struct BindGroupLayoutDescriptor<'a> { /// This will show up in graphics debuggers for easy identification. pub label: Label<'a>, /// Array of entries in this BindGroupLayout - pub entries: Cow<'a, [wgt::BindGroupLayoutEntry]>, + pub entries: Cow<'a, [BindGroupLayoutEntry]>, } diff --git a/wgpu-core-remote/src/global/device.rs b/wgpu-core-remote/src/global/device.rs index 0669f85f5..8bd6067e1 100644 --- a/wgpu-core-remote/src/global/device.rs +++ b/wgpu-core-remote/src/global/device.rs @@ -490,9 +490,29 @@ impl Global { let device = devices.get(device_id); + let entries = desc + .entries + .iter() + .map( + |&BindGroupLayoutEntry { + binding, + visibility, + ty, + }| wgt::BindGroupLayoutEntry { + binding, + visibility: wgt::ShaderStages::from_internal_flags( + visibility, + wgt::ShaderStagesWGPU::empty(), + ), + ty, + count: None, + }, + ) + .collect(); + let desc = binding_model::BindGroupLayoutDescriptor { label: desc.label.as_ref().map(|l| Cow::Borrowed(l.as_ref())), - entries: Cow::Borrowed(&desc.entries), + entries: Cow::Owned(entries), }; let bgl = device.create_bind_group_layout(&desc);