From 6ad6278bc581844e20f92c17957702a03552e1cb Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 10 Dec 2021 01:50:08 +0000 Subject: [PATCH] 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 Reviewed-by: Kai Ninomiya Commit-Queue: Austin Eng --- src/dawn_native/BindGroupLayout.cpp | 11 ------ .../validation/UnsafeAPIValidationTests.cpp | 38 ------------------- 2 files changed, 49 deletions(-) diff --git a/src/dawn_native/BindGroupLayout.cpp b/src/dawn_native/BindGroupLayout.cpp index f6687cbd68..0e6d15fd5a 100644 --- a/src/dawn_native/BindGroupLayout.cpp +++ b/src/dawn_native/BindGroupLayout.cpp @@ -89,17 +89,6 @@ namespace dawn_native { 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 9739c804e7..43cddfab02 100644 --- a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp +++ b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp @@ -28,44 +28,6 @@ class UnsafeAPIValidationTest : public ValidationTest { } }; -// 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) {