766: Validate set_bind_group is within bounds of limit r=kvark a=cwfitzgerald

**Connections**

~~Don't think there are any.~~ Would provide a nicer error message for https://github.com/gfx-rs/wgpu-rs/issues/411.

**Description**

Implements checks related to our only limit.

**Testing**

Untested


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
bors[bot]
2020-07-07 19:26:07 +00:00
committed by GitHub
3 changed files with 21 additions and 0 deletions

View File

@@ -528,6 +528,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
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..];

View File

@@ -157,6 +157,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
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..];

View File

@@ -875,6 +875,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
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..];