From 80cf5e51ccd842ebef0e1c1ae9b37ffa780801b2 Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Tue, 2 May 2023 22:29:23 +0000 Subject: [PATCH] d3d11: enable some compute shader tests Known issues: d3d11 buffer cannot be uniform and storage at same time. DispatchWorkgroupsIndirect doesn't work correctly. Bug: dawn:1705 Bug: dawn:1791 Bug: dawn:1792 Change-Id: I14df33c441198fcde9063ad85251da30c4b12c6a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131060 Commit-Queue: Peng Huang Kokoro: Kokoro Reviewed-by: Austin Eng --- .../d3d11/CommandRecordingContextD3D11.cpp | 4 ++++ src/dawn/tests/end2end/ComputeDispatchTests.cpp | 4 ++++ .../tests/end2end/ComputeFlowControlTests.cpp | 1 + .../end2end/ComputeLayoutMemoryBufferTests.cpp | 17 +++++++++++++---- .../tests/end2end/ComputeSharedMemoryTests.cpp | 1 + 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp index 03bd81a93c..bfbc052731 100644 --- a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp +++ b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp @@ -66,6 +66,8 @@ MaybeError CommandRecordingContext::Open(Device* device) { ID3D11Buffer* bufferPtr = mUniformBuffer->GetD3D11Buffer(); mD3D11DeviceContext4->VSSetConstantBuffers(PipelineLayout::kReservedConstantBufferSlot, 1, &bufferPtr); + mD3D11DeviceContext4->CSSetConstantBuffers(PipelineLayout::kReservedConstantBufferSlot, 1, + &bufferPtr); } mIsOpen = true; @@ -112,6 +114,8 @@ void CommandRecordingContext::Release() { ID3D11Buffer* nullBuffer = nullptr; mD3D11DeviceContext4->VSSetConstantBuffers(PipelineLayout::kReservedConstantBufferSlot, 1, &nullBuffer); + mD3D11DeviceContext4->CSSetConstantBuffers(PipelineLayout::kReservedConstantBufferSlot, 1, + &nullBuffer); mD3D11DeviceContext4 = nullptr; mD3D11Device = nullptr; } diff --git a/src/dawn/tests/end2end/ComputeDispatchTests.cpp b/src/dawn/tests/end2end/ComputeDispatchTests.cpp index 23555a5a46..802ae741d6 100644 --- a/src/dawn/tests/end2end/ComputeDispatchTests.cpp +++ b/src/dawn/tests/end2end/ComputeDispatchTests.cpp @@ -107,6 +107,9 @@ class ComputeDispatchTests : public DawnTest { void IndirectTest(std::vector indirectBufferData, uint64_t indirectOffset, bool useNumWorkgroups = true) { + // TODO(dawn:1791): fix indirect dispatch on D3D11 + DAWN_SUPPRESS_TEST_IF(IsD3D11()); + // Set up dst storage buffer to contain dispatch x, y, z wgpu::Buffer dst = utils::CreateBufferFromData( device, @@ -311,6 +314,7 @@ TEST_P(ComputeDispatchTests, ExceedsMaxWorkgroupsWithOffsetNoop) { } DAWN_INSTANTIATE_TEST(ComputeDispatchTests, + D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), diff --git a/src/dawn/tests/end2end/ComputeFlowControlTests.cpp b/src/dawn/tests/end2end/ComputeFlowControlTests.cpp index 933ffafe10..6c22093898 100644 --- a/src/dawn/tests/end2end/ComputeFlowControlTests.cpp +++ b/src/dawn/tests/end2end/ComputeFlowControlTests.cpp @@ -500,6 +500,7 @@ fn main() { } DAWN_INSTANTIATE_TEST(ComputeFlowControlTests, + D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), diff --git a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp index 734d82c361..815e2076ef 100644 --- a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp +++ b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp @@ -528,6 +528,12 @@ TEST_P(ComputeLayoutMemoryBufferTests, StructMember) { // TODO(crbug.com/dawn/1606): find out why these tests fail on Windows for OpenGL. DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES() && IsWindows()); + const bool isUniform = GetParam().mAddressSpace == AddressSpace::Uniform; + + // D3D11 doesn't support storage buffer with uniform address space + // TODO(dawn:1792): figure how to support it on D3D11 + DAWN_SUPPRESS_TEST_IF(IsD3D11() && isUniform); + // Sentinel value markers codes used to check that the start and end of // structures are correctly aligned. Each of these codes are distinct and // are not likely to be confused with data. @@ -549,8 +555,6 @@ TEST_P(ComputeLayoutMemoryBufferTests, StructMember) { return; } - const bool isUniform = GetParam().mAddressSpace == AddressSpace::Uniform; - std::string shader = std::string(field.IsRequireF16Feature() ? "enable f16;" : "") + R"( struct Data { @@ -699,6 +703,12 @@ TEST_P(ComputeLayoutMemoryBufferTests, NonStructMember) { // TODO(crbug.com/dawn/1606): find out why these tests fail on Windows for OpenGL. DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES() && IsWindows()); + const bool isUniform = GetParam().mAddressSpace == AddressSpace::Uniform; + + // D3D11 doesn't support storage buffer with uniform address space + // TODO(dawn:1792): figure how to support it on D3D11 + DAWN_SUPPRESS_TEST_IF(IsD3D11() && isUniform); + auto params = GetParam(); Field& field = params.mField; @@ -712,8 +722,6 @@ TEST_P(ComputeLayoutMemoryBufferTests, NonStructMember) { return; } - const bool isUniform = GetParam().mAddressSpace == AddressSpace::Uniform; - std::string shader = std::string(field.IsRequireF16Feature() ? "enable f16;" : "") + R"( @group(0) @binding(0) var<{input_qualifiers}> input : {field_type}; @@ -778,6 +786,7 @@ fn main() { auto GenerateParams() { auto params = MakeParamGenerator( { + D3D11Backend(), D3D12Backend(), D3D12Backend({"use_dxc"}), MetalBackend(), diff --git a/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp b/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp index e3955176b6..57ad5b6118 100644 --- a/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp +++ b/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp @@ -197,6 +197,7 @@ TEST_P(ComputeSharedMemoryTests, AssortedTypes) { } DAWN_INSTANTIATE_TEST(ComputeSharedMemoryTests, + D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(),