Fix BindGroupLayoutEntry validation message for no bindings types set
Fixed: dawn:1318
Change-Id: I9c5953d77c9758f0814fa50a98f5f813daf5e705
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/83061
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/BindGroupLayout.cpp b/src/dawn/native/BindGroupLayout.cpp
index 9f5e151..f535545 100644
--- a/src/dawn/native/BindGroupLayout.cpp
+++ b/src/dawn/native/BindGroupLayout.cpp
@@ -141,6 +141,10 @@
bindingType = BindingInfoType::ExternalTexture;
}
+ DAWN_INVALID_IF(bindingMemberCount == 0,
+ "BindGroupLayoutEntry had none of buffer, sampler, texture, "
+ "storageTexture, or externalTexture set");
+
DAWN_INVALID_IF(bindingMemberCount != 1,
"BindGroupLayoutEntry had more than one of buffer, sampler, texture, "
"storageTexture, or externalTexture set");
diff --git a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
index 95ffef1..87a2c3c 100644
--- a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
@@ -964,6 +964,33 @@
});
}
+// Test that it is invalid to create a BGL with more than one binding type set.
+TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutEntryTooManySet) {
+ wgpu::BindGroupLayoutEntry entry = {};
+ entry.binding = 0;
+ entry.visibility = wgpu::ShaderStage::Fragment;
+ entry.buffer.type = wgpu::BufferBindingType::Uniform;
+ entry.sampler.type = wgpu::SamplerBindingType::Filtering;
+
+ wgpu::BindGroupLayoutDescriptor descriptor;
+ descriptor.entryCount = 1;
+ descriptor.entries = &entry;
+ ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor),
+ testing::HasSubstr("had more than one of"));
+}
+
+// Test that it is invalid to create a BGL with none one of buffer,
+// sampler, texture, storageTexture, or externalTexture set.
+TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutEntryNoneSet) {
+ wgpu::BindGroupLayoutEntry entry = {};
+
+ wgpu::BindGroupLayoutDescriptor descriptor;
+ descriptor.entryCount = 1;
+ descriptor.entries = &entry;
+ ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor),
+ testing::HasSubstr("had none of"));
+}
+
// This test verifies that visibility of bindings in BindGroupLayout can be none
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
utils::MakeBindGroupLayout(device,