From 93373abb2f59398a07bdb30c52008e2f28c6e0df Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Wed, 29 May 2019 00:07:37 +0000 Subject: [PATCH] Support force enabling multiple toggles in Dawn end2end tests This patch adds the support of enabling multiple toggles in Dawn end2end tests so that we can run MultisampledRenderingTests with all MSAA related toggles enabled. BUG=dawn:56 TEST=dawn_end2end_tests Change-Id: Ia1a16a25261a2eddbb0e54326eebf1188dab9c10 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7484 Reviewed-by: Austin Eng Commit-Queue: Jiawei Shao --- src/tests/DawnTest.cpp | 31 +++++++++---------- src/tests/DawnTest.h | 22 ++++++------- .../end2end/MultisampledRenderingTests.cpp | 7 +++-- .../end2end/NonzeroTextureCreationTests.cpp | 12 ++++--- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp index 9c9ab288e5..b98f0d991f 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -67,12 +67,6 @@ namespace { } } - dawn_native::DeviceDescriptor InitWorkaround(const char* forceEnabledWorkaround) { - dawn_native::DeviceDescriptor deviceDescriptor; - deviceDescriptor.forceEnabledToggles.push_back(forceEnabledWorkaround); - return deviceDescriptor; - } - struct MapReadUserdata { DawnTest* test; size_t slot; @@ -82,9 +76,15 @@ namespace { } // namespace -DawnTestParam ForceWorkaround(const DawnTestParam& originParam, const char* workaround) { +const DawnTestParam D3D12Backend(dawn_native::BackendType::D3D12); +const DawnTestParam MetalBackend(dawn_native::BackendType::Metal); +const DawnTestParam OpenGLBackend(dawn_native::BackendType::OpenGL); +const DawnTestParam VulkanBackend(dawn_native::BackendType::Vulkan); + +DawnTestParam ForceWorkarounds(const DawnTestParam& originParam, + std::initializer_list forceEnabledWorkarounds) { DawnTestParam newTestParam = originParam; - newTestParam.forceEnabledWorkaround = workaround; + newTestParam.forceEnabledWorkarounds = forceEnabledWorkarounds; return newTestParam; } @@ -307,14 +307,13 @@ void DawnTest::SetUp() { mPCIInfo = backendAdapter.GetPCIInfo(); - const char* forceEnabledWorkaround = GetParam().forceEnabledWorkaround; - if (forceEnabledWorkaround != nullptr) { + DawnDevice backendDevice; + for (const char* forceEnabledWorkaround : GetParam().forceEnabledWorkarounds) { ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr); - dawn_native::DeviceDescriptor deviceDescriptor = InitWorkaround(forceEnabledWorkaround); - backendDevice = backendAdapter.CreateDevice(&deviceDescriptor); - } else { - backendDevice = backendAdapter.CreateDevice(nullptr); } + dawn_native::DeviceDescriptor deviceDescriptor; + deviceDescriptor.forceEnabledToggles = GetParam().forceEnabledWorkarounds; + backendDevice = backendAdapter.CreateDevice(&deviceDescriptor); backendProcs = dawn_native::GetProcs(); @@ -639,8 +638,8 @@ namespace detail { std::ostringstream ostream; ostream << ParamName(info.param.backendType); - if (info.param.forceEnabledWorkaround != nullptr) { - ostream << "_" << info.param.forceEnabledWorkaround; + for (const char* forceEnabledWorkaround : info.param.forceEnabledWorkarounds) { + ostream << "_" << forceEnabledWorkaround; } return ostream.str(); diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h index e31ec2eda7..7495cad037 100644 --- a/src/tests/DawnTest.h +++ b/src/tests/DawnTest.h @@ -19,6 +19,7 @@ #include #include +#include // Getting data back from Dawn is done in an async manners so all expectations are "deferred" // until the end of the test. Also expectations use a copy to a MapRead buffer to get the data @@ -63,34 +64,33 @@ struct RGBA8 { std::ostream& operator<<(std::ostream& stream, const RGBA8& color); struct DawnTestParam { - constexpr explicit DawnTestParam(dawn_native::BackendType backendType) - : backendType(backendType) { + explicit DawnTestParam(dawn_native::BackendType backendType) : backendType(backendType) { } dawn_native::BackendType backendType; - // TODO(jiawei.shao@intel.com): support enabling and disabling multiple workarounds. - const char* forceEnabledWorkaround = nullptr; + std::vector forceEnabledWorkarounds; }; // Shorthands for backend types used in the DAWN_INSTANTIATE_TEST -static constexpr DawnTestParam D3D12Backend(dawn_native::BackendType::D3D12); -static constexpr DawnTestParam MetalBackend(dawn_native::BackendType::Metal); -static constexpr DawnTestParam OpenGLBackend(dawn_native::BackendType::OpenGL); -static constexpr DawnTestParam VulkanBackend(dawn_native::BackendType::Vulkan); +extern const DawnTestParam D3D12Backend; +extern const DawnTestParam MetalBackend; +extern const DawnTestParam OpenGLBackend; +extern const DawnTestParam VulkanBackend; -DawnTestParam ForceWorkaround(const DawnTestParam& originParam, const char* workaround); +DawnTestParam ForceWorkarounds(const DawnTestParam& originParam, + std::initializer_list forceEnabledWorkarounds); struct GLFWwindow; namespace utils { class BackendBinding; class TerribleCommandBuffer; -} +} // namespace utils namespace detail { class Expectation; -} +} // namespace detail namespace dawn_wire { class WireClient; diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index 0f1806d7bc..82d5cf540d 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -511,5 +511,8 @@ DAWN_INSTANTIATE_TEST(MultisampledRenderingTest, MetalBackend, OpenGLBackend, VulkanBackend, - ForceWorkaround(MetalBackend, "emulate_store_and_msaa_resolve"), - ForceWorkaround(MetalBackend, "always_resolve_into_zero_level_and_layer")); + ForceWorkarounds(MetalBackend, {"emulate_store_and_msaa_resolve"}), + ForceWorkarounds(MetalBackend, {"always_resolve_into_zero_level_and_layer"}), + ForceWorkarounds(MetalBackend, + {"always_resolve_into_zero_level_and_layer", + "emulate_store_and_msaa_resolve"})); diff --git a/src/tests/end2end/NonzeroTextureCreationTests.cpp b/src/tests/end2end/NonzeroTextureCreationTests.cpp index cbb523265e..571b7f2e4c 100644 --- a/src/tests/end2end/NonzeroTextureCreationTests.cpp +++ b/src/tests/end2end/NonzeroTextureCreationTests.cpp @@ -94,8 +94,10 @@ TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) { EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, kSize, kSize, 0, 2); } -DAWN_INSTANTIATE_TEST( - NonzeroTextureCreationTests, - ForceWorkaround(D3D12Backend, "nonzero_clear_resources_on_creation_for_testing"), - ForceWorkaround(OpenGLBackend, "nonzero_clear_resources_on_creation_for_testing"), - ForceWorkaround(VulkanBackend, "nonzero_clear_resources_on_creation_for_testing")); +DAWN_INSTANTIATE_TEST(NonzeroTextureCreationTests, + ForceWorkarounds(D3D12Backend, + {"nonzero_clear_resources_on_creation_for_testing"}), + ForceWorkarounds(OpenGLBackend, + {"nonzero_clear_resources_on_creation_for_testing"}), + ForceWorkarounds(VulkanBackend, + {"nonzero_clear_resources_on_creation_for_testing"}));