Fix bind group binding ID validation. (#227)

* Fix bind group binding ID validation.

Use the binding, not the iterator index.
This commit is contained in:
Stephen White 2018-07-19 09:52:31 -04:00 committed by GitHub
parent 846cfe3421
commit 1184e46f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -36,7 +36,8 @@ namespace backend {
DAWN_TRY(ValidateShaderStageBit(binding.visibility)); DAWN_TRY(ValidateShaderStageBit(binding.visibility));
DAWN_TRY(ValidateBindingType(binding.type)); DAWN_TRY(ValidateBindingType(binding.type));
DAWN_TRY_ASSERT(!bindingsSet[i], "some binding index was specified more than once"); DAWN_TRY_ASSERT(!bindingsSet[binding.binding],
"some binding index was specified more than once");
bindingsSet.set(binding.binding); bindingsSet.set(binding.binding);
} }
return {}; return {};

View File

@ -122,3 +122,13 @@ TEST_F(BindGroupValidationTest, BindGroupLayoutCache) {
// Caching should cause these to be the same. // Caching should cause these to be the same.
ASSERT_EQ(layout1.Get(), layout2.Get()); ASSERT_EQ(layout1.Get(), layout2.Get());
} }
// This test verifies that the BindGroupLayout bindings are correctly validated, even if the
// binding ids are out-of-order.
TEST_F(BindGroupValidationTest, BindGroupBinding) {
auto layout = utils::MakeBindGroupLayout(
device, {
{1, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
});
}