Skip to content

Commit

Permalink
Replace GPUAdapter requestAdapterInfo() method with info attribute (g…
Browse files Browse the repository at this point in the history
…puweb#3679)

Fall back to requestAdapterInfo() if info doesn't exist.
  • Loading branch information
beaufortfrancois authored May 30, 2024
1 parent dcbef9c commit ebfde96
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/common/util/navigator_gpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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),
Expand All @@ -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();
3 changes: 1 addition & 2 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down
3 changes: 2 additions & 1 deletion src/webgpu/print_environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit ebfde96

Please sign in to comment.