Enable dynamic storage buffers
Validation is implemented with CTS tests added in
https://github.com/gpuweb/cts/pull/850
Fixed: dawn:429
Change-Id: Iee570c712f81fbafc158c0ceec89a28011a3fed8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71960
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/BindGroupLayout.cpp b/src/dawn_native/BindGroupLayout.cpp
index f6687cb..0e6d15f 100644
--- a/src/dawn_native/BindGroupLayout.cpp
+++ b/src/dawn_native/BindGroupLayout.cpp
@@ -89,17 +89,6 @@
buffer.type == kInternalStorageBufferBinding) {
allowedStages &= ~wgpu::ShaderStage::Vertex;
}
-
- // Dynamic storage buffers aren't bounds checked properly in D3D12. Disallow them as
- // unsafe until the bounds checks are implemented.
- DAWN_INVALID_IF(
- device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs) &&
- buffer.hasDynamicOffset &&
- (buffer.type == wgpu::BufferBindingType::Storage ||
- buffer.type == kInternalStorageBufferBinding ||
- buffer.type == wgpu::BufferBindingType::ReadOnlyStorage),
- "Dynamic storage buffers are disallowed because they aren't secure yet. "
- "See https://crbug.com/dawn/429");
}
if (entry.sampler.type != wgpu::SamplerBindingType::Undefined) {
bindingMemberCount++;
diff --git a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp
index 9739c80..43cddfa 100644
--- a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp
+++ b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp
@@ -28,44 +28,6 @@
}
};
-// Check that dynamic storage buffers are disallowed.
-TEST_F(UnsafeAPIValidationTest, DynamicStorageBuffer) {
- wgpu::BindGroupLayoutEntry entry;
- entry.visibility = wgpu::ShaderStage::Fragment;
-
- wgpu::BindGroupLayoutDescriptor desc;
- desc.entries = &entry;
- desc.entryCount = 1;
-
- // Control case: storage buffer without a dynamic offset is allowed.
- {
- entry.buffer.type = wgpu::BufferBindingType::Storage;
- entry.buffer.hasDynamicOffset = false;
- device.CreateBindGroupLayout(&desc);
- }
-
- // Control case: readonly storage buffer without a dynamic offset is allowed.
- {
- entry.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
- entry.buffer.hasDynamicOffset = false;
- device.CreateBindGroupLayout(&desc);
- }
-
- // Storage buffer with a dynamic offset is disallowed.
- {
- entry.buffer.type = wgpu::BufferBindingType::Storage;
- entry.buffer.hasDynamicOffset = true;
- ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc));
- }
-
- // Readonly storage buffer with a dynamic offset is disallowed.
- {
- entry.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
- entry.buffer.hasDynamicOffset = true;
- ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc));
- }
-}
-
// Check that pipeline overridable constants are disallowed as part of unsafe APIs.
// TODO(dawn:1041) Remove when implementation for all backend is added
TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {