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 <bajones@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2021-11-01 18:01:32 +00:00 committed by Dawn LUCI CQ
parent 777cbbb22b
commit 1722f9e78e
2 changed files with 0 additions and 48 deletions

View File

@ -295,14 +295,6 @@ namespace dawn_native {
DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect)); DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
DAWN_TRY(mCommandBufferState.ValidateCanDispatch()); 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, DAWN_INVALID_IF(indirectOffset % 4 != 0,
"Indirect offset (%u) is not a multiple of 4.", indirectOffset); "Indirect offset (%u) is not a multiple of 4.", indirectOffset);

View File

@ -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. // Check that dynamic storage buffers are disallowed.
TEST_F(UnsafeAPIValidationTest, DynamicStorageBuffer) { TEST_F(UnsafeAPIValidationTest, DynamicStorageBuffer) {
wgpu::BindGroupLayoutEntry entry; wgpu::BindGroupLayoutEntry entry;