From 2d38ff2dd6f1e87c5c650e58eabd77b7bc47eb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Fri, 14 Jun 2024 09:06:08 +0200 Subject: [PATCH] WebGPU: Use GPUAdapter GetInfo() instead of GetProperties() This CL makes sure Skia uses GPUAdapter GetInfo() instead of GetProperties() so that we can start removing GetProperties() in Dawn following on webgpu.h change[1]. [1]: https://github.com/webgpu-native/webgpu-headers/pull/305 Bug: 335383516 Change-Id: Ifb416c6e8f738fd81b0fb705ff0d19381017c0ef Reviewed-on: https://skia-review.googlesource.com/c/skia/+/866796 Reviewed-by: Greg Daniel Commit-Queue: Michael Ludwig Reviewed-by: Michael Ludwig --- AUTHORS | 1 + src/gpu/graphite/dawn/DawnCaps.cpp | 12 +++---- .../graphite/dawn/GraphiteDawnTestContext.cpp | 35 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/AUTHORS b/AUTHORS index b9e49b9eec4c..beb21c7ee06b 100755 --- a/AUTHORS +++ b/AUTHORS @@ -37,6 +37,7 @@ Deepak Mohan Ehsan Akhgari Erik Sombroek Facebook, Inc. <*fb.com> +François Beaufort George Wright GiWan Go Google Inc. <*@google.com> diff --git a/src/gpu/graphite/dawn/DawnCaps.cpp b/src/gpu/graphite/dawn/DawnCaps.cpp index fd9bfe49956a..8668f575100f 100644 --- a/src/gpu/graphite/dawn/DawnCaps.cpp +++ b/src/gpu/graphite/dawn/DawnCaps.cpp @@ -395,14 +395,14 @@ std::pair DawnCaps::supportedReadPixelsColorT } void DawnCaps::initCaps(const DawnBackendContext& backendContext, const ContextOptions& options) { - // GetAdapter() is not available in WASM and there's no way to get AdapterProperties off of + // GetAdapter() is not available in WASM and there's no way to get AdapterInfo off of // the WGPUDevice directly. #if !defined(__EMSCRIPTEN__) - wgpu::AdapterProperties props; - backendContext.fDevice.GetAdapter().GetProperties(&props); + wgpu::AdapterInfo info; + backendContext.fDevice.GetAdapter().GetInfo(&info); #if defined(GRAPHITE_TEST_UTILS) - this->setDeviceName(props.name); + this->setDeviceName(info.device); #endif #endif // defined(__EMSCRIPTEN__) @@ -435,8 +435,8 @@ void DawnCaps::initCaps(const DawnBackendContext& backendContext, const ContextO #if !defined(__EMSCRIPTEN__) // TODO(b/318817249): SSBOs trigger FXC compiler failures when attempting to unroll loops - fStorageBufferSupport = props.backendType != wgpu::BackendType::D3D11; - fStorageBufferPreferred = props.backendType != wgpu::BackendType::D3D11; + fStorageBufferSupport = info.backendType != wgpu::BackendType::D3D11; + fStorageBufferPreferred = info.backendType != wgpu::BackendType::D3D11; #else // WASM doesn't provide a way to query the backend, so can't tell if we are on d3d11 or not. // Pessimistically assume we could be. Once b/318817249 is fixed, this can go away and SSBOs diff --git a/tools/graphite/dawn/GraphiteDawnTestContext.cpp b/tools/graphite/dawn/GraphiteDawnTestContext.cpp index f056197533a4..920d5986d8c2 100644 --- a/tools/graphite/dawn/GraphiteDawnTestContext.cpp +++ b/tools/graphite/dawn/GraphiteDawnTestContext.cpp @@ -62,20 +62,19 @@ std::unique_ptr DawnTestContext::Make(wgpu::BackendType bac 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); - }); + std::sort( + adapters.begin(), adapters.end(), [](dawn::native::Adapter a, dawn::native::Adapter b) { + wgpu::AdapterInfo infoA; + wgpu::AdapterInfo infoB; + a.GetInfo(&infoA); + b.GetInfo(&infoB); + return std::tuple(infoA.adapterType, infoA.backendType) < + std::tuple(infoB.adapterType, infoB.backendType); + }); for (const auto& adapter : adapters) { - wgpu::AdapterProperties props; - adapter.GetProperties(&props); + wgpu::AdapterInfo props; + adapter.GetInfo(&props); if (backend == props.backendType) { matchedAdaptor = adapter; break; @@ -87,9 +86,9 @@ std::unique_ptr DawnTestContext::Make(wgpu::BackendType bac } #if LOG_ADAPTER - wgpu::AdapterProperties properties; - sAdapter.GetProperties(&properties); - SkDebugf("GPU: %s\nDriver: %s\n", properties.name, properties.driverDescription); + wgpu::AdapterInfo info; + sAdapter.GetInfo(&info); + SkDebugf("GPU: %s\nDriver: %s\n", info.device, info.description); #endif std::vector features; @@ -152,9 +151,9 @@ std::unique_ptr DawnTestContext::Make(wgpu::BackendType bac } skgpu::ContextType DawnTestContext::contextType() { - wgpu::AdapterProperties props; - fBackendContext.fDevice.GetAdapter().GetProperties(&props); - switch (props.backendType) { + wgpu::AdapterInfo info; + fBackendContext.fDevice.GetAdapter().GetInfo(&info); + switch (info.backendType) { case wgpu::BackendType::D3D11: return skgpu::ContextType::kDawn_D3D11;