diff options
author | Greg Daniel <egdaniel@google.com> | 2023-12-12 09:52:26 -0500 |
---|---|---|
committer | SkCQ <skcq-be@skia-corp.google.com.iam.gserviceaccount.com> | 2023-12-12 19:19:25 +0000 |
commit | 8e8d92ac15366f61d5566a09a34b4b069b7fb3c2 (patch) | |
tree | aea010569c80750aea2d2550ca84a70e47a98763 | |
parent | 43a400456ab41b8357847e38a2a7c69ec1ee8499 (diff) | |
download | skia-8e8d92ac15366f61d5566a09a34b4b069b7fb3c2.tar.gz |
Fix GraphiteDawnTestContext to allow creation of different backends.
Bug: b/315834710
Change-Id: I93fa2a544b2cb4729e59e7115175850428c8a97e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/788437
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
-rw-r--r-- | tests/graphite/ComputeTest.cpp | 25 | ||||
-rw-r--r-- | tools/graphite/dawn/GraphiteDawnTestContext.cpp | 72 |
2 files changed, 68 insertions, 29 deletions
diff --git a/tests/graphite/ComputeTest.cpp b/tests/graphite/ComputeTest.cpp index d427257b7a..88705fde7c 100644 --- a/tests/graphite/ComputeTest.cpp +++ b/tests/graphite/ComputeTest.cpp @@ -225,6 +225,11 @@ DEF_GRAPHITE_TEST_FOR_DAWN_AND_METAL_CONTEXTS(Compute_DispatchGroupTest, reporter, context, testContext) { + // This fails on Dawn D3D11, b/315834710 + if (testContext->contextType() == skgpu::ContextType::kDawn_D3D11) { + return; + } + constexpr uint32_t kProblemSize = 512; constexpr float kFactor1 = 4.f; constexpr float kFactor2 = 3.f; @@ -471,6 +476,11 @@ DEF_GRAPHITE_TEST_FOR_DAWN_AND_METAL_CONTEXTS(Compute_UniformBufferTest, reporter, context, testContext) { + // This fails on Dawn D3D11, b/315834710 + if (testContext->contextType() == skgpu::ContextType::kDawn_D3D11) { + return; + } + constexpr uint32_t kProblemSize = 512; constexpr float kFactor = 4.f; @@ -1310,6 +1320,11 @@ DEF_GRAPHITE_TEST_FOR_DAWN_AND_METAL_CONTEXTS(Compute_AtomicOperationsTest, reporter, context, testContext) { + // This fails on Dawn D3D11, b/315834710 + if (testContext->contextType() == skgpu::ContextType::kDawn_D3D11) { + return; + } + std::unique_ptr<Recorder> recorder = context->makeRecorder(); constexpr uint32_t kWorkgroupCount = 32; @@ -1435,6 +1450,11 @@ DEF_GRAPHITE_TEST_FOR_DAWN_AND_METAL_CONTEXTS(Compute_AtomicOperationsOverArrayA reporter, context, testContext) { + // This fails on Dawn D3D11, b/315834710 + if (testContext->contextType() == skgpu::ContextType::kDawn_D3D11) { + return; + } + std::unique_ptr<Recorder> recorder = context->makeRecorder(); constexpr uint32_t kWorkgroupCount = 32; @@ -1932,6 +1952,11 @@ DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT(Compute_WorkgroupBufferDescMetal, } DEF_GRAPHITE_TEST_FOR_DAWN_CONTEXT(Compute_NativeShaderSourceWGSL, reporter, context, testContext) { + // This fails on Dawn D3D11, b/315834710 + if (testContext->contextType() == skgpu::ContextType::kDawn_D3D11) { + return; + } + std::unique_ptr<Recorder> recorder = context->makeRecorder(); constexpr uint32_t kWorkgroupCount = 32; diff --git a/tools/graphite/dawn/GraphiteDawnTestContext.cpp b/tools/graphite/dawn/GraphiteDawnTestContext.cpp index 11853b5185..facd0ba7f5 100644 --- a/tools/graphite/dawn/GraphiteDawnTestContext.cpp +++ b/tools/graphite/dawn/GraphiteDawnTestContext.cpp @@ -22,9 +22,9 @@ namespace skiatest::graphite { -std::unique_ptr<GraphiteTestContext> DawnTestContext::Make(std::optional<wgpu::BackendType> backend) { +std::unique_ptr<GraphiteTestContext> DawnTestContext::Make( + std::optional<wgpu::BackendType> backend) { static std::unique_ptr<dawn::native::Instance> sInstance; - static dawn::native::Adapter sAdapter; static SkOnce sOnce; static constexpr const char* kToggles[] = { @@ -35,55 +35,69 @@ std::unique_ptr<GraphiteTestContext> DawnTestContext::Make(std::optional<wgpu::B togglesDesc.enabledToggleCount = std::size(kToggles); togglesDesc.enabledToggles = kToggles; + // Creation of Instance is cheap but calling EnumerateAdapters can be expensive the first time, + // but then the results are cached on the Instance object. So save the Instance here so we can + // avoid the overhead of EnumerateAdapters on every test. sOnce([&]{ DawnProcTable backendProcs = dawn::native::GetProcs(); dawnProcSetProcs(&backendProcs); - sInstance = std::make_unique<dawn::native::Instance>(); - wgpu::RequestAdapterOptions options; - options.nextInChain = &togglesDesc; - std::vector<dawn::native::Adapter> adapters = sInstance->EnumerateAdapters(&options); - SkASSERT(!adapters.empty()); - // Sort adapters by adapterType(DiscreteGPU, IntegratedGPU, CPU) and - // backendType(WebGPU, D3D11, D3D12, Metal, Vulkan, OpenGL, OpenGLES). - std::sort(adapters.begin(), - adapters.end(), - [](dawn::native::Adapter a, dawn::native::Adapter b) { - wgpu::AdapterProperties propA; - wgpu::AdapterProperties propB; - a.GetProperties(&propA); - b.GetProperties(&propB); - return std::tuple(propA.adapterType, propA.backendType) < - std::tuple(propB.adapterType, propB.backendType); - }); + }); + dawn::native::Adapter matchedAdaptor; + + wgpu::RequestAdapterOptions options; + options.nextInChain = &togglesDesc; + std::vector<dawn::native::Adapter> adapters = sInstance->EnumerateAdapters(&options); + SkASSERT(!adapters.empty()); + // Sort adapters by adapterType(DiscreteGPU, IntegratedGPU, CPU) and + // backendType(WebGPU, D3D11, D3D12, Metal, Vulkan, OpenGL, OpenGLES). + std::sort(adapters.begin(), + adapters.end(), + [](dawn::native::Adapter a, dawn::native::Adapter b) { + wgpu::AdapterProperties propA; + wgpu::AdapterProperties propB; + a.GetProperties(&propA); + b.GetProperties(&propB); + return std::tuple(propA.adapterType, propA.backendType) < + std::tuple(propB.adapterType, propB.backendType); + }); + + if (backend.has_value()) { for (const auto& adapter : adapters) { wgpu::AdapterProperties props; adapter.GetProperties(&props); - if (backend.has_value() && backend.value() == props.backendType) { - sAdapter = adapter; + if (backend.value() == props.backendType) { + matchedAdaptor = adapter; break; } + } + } else { + for (const auto& adapter : adapters) { + wgpu::AdapterProperties props; + adapter.GetProperties(&props); // We never want a null/undefined backend. // Skip Dawn D3D11 backend for now. if (props.backendType != wgpu::BackendType::Null && props.backendType != wgpu::BackendType::Undefined && props.backendType != wgpu::BackendType::D3D11) { - sAdapter = adapter; + matchedAdaptor = adapter; break; } } - SkASSERT(sAdapter); + } + if (!matchedAdaptor) { + return nullptr; + } #if LOG_ADAPTER - wgpu::AdapterProperties properties; - sAdapter.GetProperties(&properties); - SkDebugf("GPU: %s\nDriver: %s\n", properties.name, properties.driverDescription); + wgpu::AdapterProperties properties; + sAdapter.GetProperties(&properties); + SkDebugf("GPU: %s\nDriver: %s\n", properties.name, properties.driverDescription); #endif - }); std::vector<wgpu::FeatureName> features; - wgpu::Adapter adapter = sAdapter.Get(); + wgpu::Adapter adapter = matchedAdaptor.Get(); if (adapter.HasFeature(wgpu::FeatureName::MSAARenderToSingleSampled)) { features.push_back(wgpu::FeatureName::MSAARenderToSingleSampled); } @@ -105,7 +119,7 @@ std::unique_ptr<GraphiteTestContext> DawnTestContext::Make(std::optional<wgpu::B desc.requiredFeatures = features.data(); desc.nextInChain = &togglesDesc; - wgpu::Device device = wgpu::Device::Acquire(sAdapter.CreateDevice(&desc)); + wgpu::Device device = wgpu::Device::Acquire(matchedAdaptor.CreateDevice(&desc)); SkASSERT(device); device.SetUncapturedErrorCallback( [](WGPUErrorType type, const char* message, void*) { |