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>
This commit is contained in:
Austin Eng 2022-03-09 00:07:31 +00:00 committed by Dawn LUCI CQ
parent 1a73be4107
commit 5073fb5685
2 changed files with 31 additions and 0 deletions

View File

@ -141,6 +141,10 @@ namespace dawn::native {
bindingType = BindingInfoType::ExternalTexture; bindingType = BindingInfoType::ExternalTexture;
} }
DAWN_INVALID_IF(bindingMemberCount == 0,
"BindGroupLayoutEntry had none of buffer, sampler, texture, "
"storageTexture, or externalTexture set");
DAWN_INVALID_IF(bindingMemberCount != 1, DAWN_INVALID_IF(bindingMemberCount != 1,
"BindGroupLayoutEntry had more than one of buffer, sampler, texture, " "BindGroupLayoutEntry had more than one of buffer, sampler, texture, "
"storageTexture, or externalTexture set"); "storageTexture, or externalTexture set");

View File

@ -964,6 +964,33 @@ TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) {
}); });
} }
// 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 // This test verifies that visibility of bindings in BindGroupLayout can be none
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) { TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
utils::MakeBindGroupLayout(device, utils::MakeBindGroupLayout(device,