Validate there are at most kMaxBindingsPerGroup entries per layout.
This is a regression that was caught by the WebGPU CTS after https://dawn-review.googlesource.com/c/dawn/+/17240 where the BindGroupLayout validation was changed to use a set, and the check for KMaxBindingsPerGroup removed. This CL also adds a regression test. Bug: dawn:354 Change-Id: I0cda545b9df7220ca53216878cf24ac8ce880648 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/17620 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
4a858a0cbd
commit
4c6c40d47d
|
@ -152,6 +152,10 @@ namespace dawn_native {
|
|||
bindingsSet.insert(bindingNumber);
|
||||
}
|
||||
|
||||
if (bindingsSet.size() > kMaxBindingsPerGroup) {
|
||||
return DAWN_VALIDATION_ERROR("The number of bindings exceeds kMaxBindingsPerGroup.");
|
||||
}
|
||||
|
||||
if (dynamicUniformBufferCount > kMaxDynamicUniformBufferCount) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"The number of dynamic uniform buffer exceeds the maximum value");
|
||||
|
|
|
@ -521,6 +521,28 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutBindingUnbounded) {
|
|||
wgpu::BindingType::UniformBuffer}});
|
||||
}
|
||||
|
||||
// Test that there can't be more than kMaxBindingPerGroup bindings per group
|
||||
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutMaxBindings) {
|
||||
wgpu::BindGroupLayoutBinding bindings[kMaxBindingsPerGroup + 1];
|
||||
|
||||
for (uint32_t i = 0; i < kMaxBindingsPerGroup + 1; i++) {
|
||||
bindings[i].type = wgpu::BindingType::UniformBuffer;
|
||||
bindings[i].binding = i;
|
||||
bindings[i].visibility = wgpu::ShaderStage::Compute;
|
||||
}
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc;
|
||||
desc.bindings = bindings;
|
||||
|
||||
// Control case: kMaxBindingsPerGroup bindings is allowed.
|
||||
desc.bindingCount = kMaxBindingsPerGroup;
|
||||
device.CreateBindGroupLayout(&desc);
|
||||
|
||||
// Error case: kMaxBindingsPerGroup + 1 bindings is not allowed.
|
||||
desc.bindingCount = kMaxBindingsPerGroup + 1;
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc));
|
||||
}
|
||||
|
||||
// This test verifies that the BindGroupLayout bindings are correctly validated, even if the
|
||||
// binding ids are out-of-order.
|
||||
TEST_F(BindGroupLayoutValidationTest, BindGroupBinding) {
|
||||
|
|
Loading…
Reference in New Issue