From 8f98c64d41756c8cb3ed2be017789aa95a7460cb Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 4 Sep 2020 15:41:37 -0400 Subject: [PATCH] Don't bind groups that aren't expected by the layout --- wgpu-core/src/command/bind.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wgpu-core/src/command/bind.rs b/wgpu-core/src/command/bind.rs index ba1c3296b..a9c1be7a3 100644 --- a/wgpu-core/src/command/bind.rs +++ b/wgpu-core/src/command/bind.rs @@ -112,11 +112,12 @@ impl BindGroupEntry { } } - fn is_valid(&self) -> bool { + fn is_valid(&self) -> Option { match (self.expected_layout_id, self.provided.as_ref()) { - (None, _) => true, - (Some(_), None) => false, - (Some(layout), Some(pair)) => layout == pair.layout_id, + (None, None) => Some(true), + (None, Some(_)) => None, + (Some(_), None) => Some(false), + (Some(layout), Some(pair)) => Some(layout == pair.layout_id), } } @@ -220,7 +221,7 @@ impl Binder { pub(super) fn invalid_mask(&self) -> BindGroupMask { self.entries.iter().enumerate().fold(0, |mask, (i, entry)| { - if entry.is_valid() { + if entry.is_valid().unwrap_or(true) { mask } else { mask | 1u8 << i @@ -231,7 +232,7 @@ impl Binder { fn compatible_count(&self) -> usize { self.entries .iter() - .position(|entry| !entry.is_valid()) + .position(|entry| !entry.is_valid().unwrap_or(false)) .unwrap_or_else(|| self.entries.len()) } }