Skip to content

Commit

Permalink
WebGPU: Use GPUAdapter GetInfo() instead of GetProperties()
Browse files Browse the repository at this point in the history
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]: webgpu-native/webgpu-headers#305

Bug: 335383516
Change-Id: Ifb416c6e8f738fd81b0fb705ff0d19381017c0ef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/866796
Reviewed-by: Greg Daniel <[email protected]>
Commit-Queue: Michael Ludwig <[email protected]>
Reviewed-by: Michael Ludwig <[email protected]>
  • Loading branch information
beaufortfrancois authored and SkCQ committed Jun 17, 2024
1 parent 4040aa6 commit 2d38ff2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Deepak Mohan <[email protected]>
Ehsan Akhgari <[email protected]>
Erik Sombroek <[email protected]>
Facebook, Inc. <*fb.com>
François Beaufort <[email protected]>
George Wright <[email protected]>
GiWan Go <[email protected]>
Google Inc. <*@google.com>
Expand Down
12 changes: 6 additions & 6 deletions src/gpu/graphite/dawn/DawnCaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,14 @@ std::pair<SkColorType, bool /*isRGBFormat*/> 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__)

Expand Down Expand Up @@ -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
Expand Down
35 changes: 17 additions & 18 deletions tools/graphite/dawn/GraphiteDawnTestContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,19 @@ std::unique_ptr<GraphiteTestContext> 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;
Expand All @@ -87,9 +86,9 @@ std::unique_ptr<GraphiteTestContext> 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<wgpu::FeatureName> features;
Expand Down Expand Up @@ -152,9 +151,9 @@ std::unique_ptr<GraphiteTestContext> 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;

Expand Down

0 comments on commit 2d38ff2

Please sign in to comment.