diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index cfb7cc4a20..e5aa06391f 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -528,6 +528,13 @@ impl Global { num_dynamic_offsets, bind_group_id, } => { + assert!( + (index as u32) < device.limits.max_bind_groups, + "Bind group index {0} is out of range 0..{1} provided by requested max_bind_group limit {1}", + index, + device.limits.max_bind_groups + ); + let offsets = &base.dynamic_offsets[..num_dynamic_offsets as usize]; base.dynamic_offsets = &base.dynamic_offsets[num_dynamic_offsets as usize..]; diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 83ab55451c..a06c337ad4 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -157,6 +157,13 @@ impl Global { num_dynamic_offsets, bind_group_id, } => { + assert!( + (index as u32) < cmb.limits.max_bind_groups, + "Bind group index {0} is out of range 0..{1} provided by requested max_bind_group limit {1}", + index, + cmb.limits.max_bind_groups + ); + let offsets = &base.dynamic_offsets[..num_dynamic_offsets as usize]; base.dynamic_offsets = &base.dynamic_offsets[num_dynamic_offsets as usize..]; diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 23314e2a94..cb5f6ae173 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -875,6 +875,13 @@ impl Global { num_dynamic_offsets, bind_group_id, } => { + assert!( + (index as u32) < device.limits.max_bind_groups, + "Bind group index {0} is out of range 0..{1} provided by requested max_bind_group limit {1}", + index, + device.limits.max_bind_groups + ); + let offsets = &base.dynamic_offsets[..num_dynamic_offsets as usize]; base.dynamic_offsets = &base.dynamic_offsets[num_dynamic_offsets as usize..];