From 1722f9e78e64e98a83ba25f5533f3d1932ebbbcb Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Mon, 1 Nov 2021 18:01:32 +0000 Subject: [PATCH] Unmark DispatchIndirect as an unsafe API Validation is now implemented. end2end_tests added in https://dawn-review.googlesource.com/c/dawn/+/67142 CTS tests enabled in https://chromium-review.googlesource.com/c/chromium/src/+/3254613 Fixed: dawn:1039 Change-Id: I03ae6bba4f11d6fa0aa2a83f3b6d72aa43c5e2df Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68040 Reviewed-by: Brandon Jones Reviewed-by: Loko Kung Commit-Queue: Austin Eng --- src/dawn_native/ComputePassEncoder.cpp | 8 ---- .../validation/UnsafeAPIValidationTests.cpp | 40 ------------------- 2 files changed, 48 deletions(-) diff --git a/src/dawn_native/ComputePassEncoder.cpp b/src/dawn_native/ComputePassEncoder.cpp index 05c68fb11c..c12c15a6bf 100644 --- a/src/dawn_native/ComputePassEncoder.cpp +++ b/src/dawn_native/ComputePassEncoder.cpp @@ -295,14 +295,6 @@ namespace dawn_native { DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect)); DAWN_TRY(mCommandBufferState.ValidateCanDispatch()); - // Indexed dispatches need a compute-shader based validation to check that the - // dispatch sizes aren't too big. Disallow them as unsafe until the validation - // is implemented. - DAWN_INVALID_IF( - GetDevice()->IsToggleEnabled(Toggle::DisallowUnsafeAPIs), - "DispatchIndirect is disallowed because it doesn't validate that the " - "dispatch size is valid yet."); - DAWN_INVALID_IF(indirectOffset % 4 != 0, "Indirect offset (%u) is not a multiple of 4.", indirectOffset); diff --git a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp index 624305b015..8d0e9f7a6d 100644 --- a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp +++ b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp @@ -28,46 +28,6 @@ class UnsafeAPIValidationTest : public ValidationTest { } }; -// Check that DispatchIndirect is disallowed as part of unsafe APIs. -TEST_F(UnsafeAPIValidationTest, DispatchIndirectDisallowed) { - // Create the index and indirect buffers. - wgpu::BufferDescriptor indirectBufferDesc; - indirectBufferDesc.size = 64; - indirectBufferDesc.usage = wgpu::BufferUsage::Indirect; - wgpu::Buffer indirectBuffer = device.CreateBuffer(&indirectBufferDesc); - - // Create the dummy compute pipeline. - wgpu::ComputePipelineDescriptor pipelineDesc; - pipelineDesc.compute.entryPoint = "main"; - pipelineDesc.compute.module = - utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}"); - wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc); - - // Control case: dispatch is allowed. - { - wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - wgpu::ComputePassEncoder pass = encoder.BeginComputePass(); - - pass.SetPipeline(pipeline); - pass.Dispatch(1, 1, 1); - - pass.EndPass(); - encoder.Finish(); - } - - // Error case: dispatch indirect is disallowed. - { - wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - wgpu::ComputePassEncoder pass = encoder.BeginComputePass(); - - pass.SetPipeline(pipeline); - pass.DispatchIndirect(indirectBuffer, 0); - - pass.EndPass(); - ASSERT_DEVICE_ERROR(encoder.Finish()); - } -} - // Check that dynamic storage buffers are disallowed. TEST_F(UnsafeAPIValidationTest, DynamicStorageBuffer) { wgpu::BindGroupLayoutEntry entry;