diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 5d6ef973a..916a3150c 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -1160,6 +1160,7 @@ pub struct BindGroup { pub(crate) used: BindGroupStates, pub(crate) used_buffer_ranges: Vec, pub(crate) used_texture_ranges: Vec, + /// INVARIANT: Sorted by binding index order. pub(crate) dynamic_binding_info: Vec, /// Actual binding sizes for buffers that don't have `min_binding_size` /// specified in BGL. Listed in the order of iteration of `BGL.entries`. diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index dec178a5b..47aab4241 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -3377,6 +3377,9 @@ impl Device { return Err(Error::DuplicateBinding(a.binding)); } } + + dynamic_binding_info.sort_by_key(|i| i.binding_idx); + let hal_desc = hal::BindGroupDescriptor { label: desc.label.to_hal(self.instance_flags), layout: layout.raw(),