From ebfde9659b5b69bef2fb4a864033f5c6807c4220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Thu, 30 May 2024 23:40:52 +0200 Subject: [PATCH] Replace GPUAdapter requestAdapterInfo() method with info attribute (#3679) Fall back to requestAdapterInfo() if info doesn't exist. --- src/common/util/navigator_gpu.ts | 3 ++- ...equestAdapterInfo.spec.ts => info.spec.ts} | 21 ++++--------------- src/webgpu/listing_meta.json | 3 +-- src/webgpu/print_environment.spec.ts | 3 ++- 4 files changed, 9 insertions(+), 21 deletions(-) rename src/webgpu/api/operation/adapter/{requestAdapterInfo.spec.ts => info.spec.ts} (66%) diff --git a/src/common/util/navigator_gpu.ts b/src/common/util/navigator_gpu.ts index 47adecc59ef8..6f3a423db39f 100644 --- a/src/common/util/navigator_gpu.ts +++ b/src/common/util/navigator_gpu.ts @@ -70,7 +70,8 @@ export function getGPU(recorder: TestCaseRecorder | null): GPU { if (recorder) { void promise.then(async adapter => { if (adapter) { - const info = await adapter.requestAdapterInfo(); + // MAINTENANCE_TODO: Remove requestAdapterInfo when info is implemented. + const info = adapter.info || (await adapter.requestAdapterInfo()); const infoString = `Adapter: ${info.vendor} / ${info.architecture} / ${info.device}`; recorder.debug(new ErrorWithExtra(infoString, () => ({ adapterInfo: info }))); } diff --git a/src/webgpu/api/operation/adapter/requestAdapterInfo.spec.ts b/src/webgpu/api/operation/adapter/info.spec.ts similarity index 66% rename from src/webgpu/api/operation/adapter/requestAdapterInfo.spec.ts rename to src/webgpu/api/operation/adapter/info.spec.ts index 8a85d74773c0..ee5c4e86c57f 100644 --- a/src/webgpu/api/operation/adapter/requestAdapterInfo.spec.ts +++ b/src/webgpu/api/operation/adapter/info.spec.ts @@ -1,8 +1,5 @@ export const description = ` -Tests various ways of calling GPUAdapter.requestAdapterInfo. - -TODO: -- Find a way to perform tests with and without user activation +Tests GPUAdapter.info members formatting. `; import { Fixture } from '../../../../common/framework/fixture.js'; @@ -17,16 +14,15 @@ const normalizedIdentifierRegex = /^$|^[a-z0-9]+(-[a-z0-9]+)*$/; g.test('adapter_info') .desc( ` - Test that calling requestAdapterInfo with no arguments: - - Returns a GPUAdapterInfo structure - - Every member in the structure except description is properly formatted` + Test that every member in the GPUAdapter.info except description is properly formatted` ) .fn(async t => { const gpu = getGPU(t.rec); const adapter = await gpu.requestAdapter(); assert(adapter !== null); - const adapterInfo = await adapter.requestAdapterInfo(); + const adapterInfo = adapter.info; + assert(adapterInfo instanceof GPUAdapterInfo); t.expect( normalizedIdentifierRegex.test(adapterInfo.vendor), @@ -43,12 +39,3 @@ g.test('adapter_info') `adapterInfo.device should be a normalized identifier. But it's '${adapterInfo.device}'` ); }); - -g.test('adapter_info_with_hints') - .desc( - ` - Test that calling requestAdapterInfo with hints: - - Rejects without user activation - - Succeed with user activation` - ) - .unimplemented(); diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index e5e0c06aa383..b251aa443fe3 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -1,9 +1,8 @@ { "_comment": "SEMI AUTO-GENERATED. This list is NOT exhaustive. Please read docs/adding_timing_metadata.md.", + "webgpu:api,operation,adapter,info:adapter_info:*": { "subcaseMS": 32.901 }, "webgpu:api,operation,adapter,requestAdapter:requestAdapter:*": { "subcaseMS": 152.083 }, "webgpu:api,operation,adapter,requestAdapter:requestAdapter_no_parameters:*": { "subcaseMS": 384.601 }, - "webgpu:api,operation,adapter,requestAdapterInfo:adapter_info:*": { "subcaseMS": 136.601 }, - "webgpu:api,operation,adapter,requestAdapterInfo:adapter_info_with_hints:*": { "subcaseMS": 0.101 }, "webgpu:api,operation,adapter,requestDevice:default:*": { "subcaseMS": 19.450 }, "webgpu:api,operation,adapter,requestDevice:features,known:*": { "subcaseMS": 9.637 }, "webgpu:api,operation,adapter,requestDevice:features,unknown:*": { "subcaseMS": 13.600 }, diff --git a/src/webgpu/print_environment.spec.ts b/src/webgpu/print_environment.spec.ts index 44a34c22cbb8..a450637be807 100644 --- a/src/webgpu/print_environment.spec.ts +++ b/src/webgpu/print_environment.spec.ts @@ -36,7 +36,8 @@ in the logs. On non-WPT runtimes, it will also print to the console with console WPT disallows console.log and doesn't support logs on passing tests, so this does nothing on WPT.` ) .fn(async t => { - const adapterInfo = await t.adapter.requestAdapterInfo(); + // MAINTENANCE_TODO: Remove requestAdapterInfo when info is implemented. + const adapterInfo = t.adapter.info || (await t.adapter.requestAdapterInfo()); const info = JSON.stringify( {