diff --git a/package-lock.json b/package-lock.json index 5768ae3b5761..cd59eb95b21c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "@types/w3c-image-capture": "^1.0.10", "@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/parser": "^6.9.1", - "@webgpu/types": "^0.1.50", + "@webgpu/types": "^0.1.51", "ansi-colors": "4.1.3", "babel-plugin-add-header-comment": "^1.0.3", "babel-plugin-const-enum": "^1.2.0", @@ -1539,9 +1539,15 @@ "dev": true }, "node_modules/@webgpu/types": { +<<<<<<< HEAD + "version": "0.1.51", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.51.tgz", + "integrity": "sha512-ktR3u64NPjwIViNCck+z9QeyN0iPkQCUOQ07ZCV1RzlkfP+olLTeEZ95O1QHS+v4w9vJeY9xj/uJuSphsHy5rQ==", +======= "version": "0.1.50", "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.50.tgz", "integrity": "sha512-GjG3CQV7SyWk/lEXqFPuKchRPHIBbD317Gj8NUqqB+UOnQlOYtjGLCTRIWzO9Ta698LVzlBCSE9XKqBSWpIDmg==", +>>>>>>> 8a80203467ffcb3f87bb6a7f74655a6e1043d051 "dev": true, "license": "BSD-3-Clause" }, @@ -10077,9 +10083,15 @@ "dev": true }, "@webgpu/types": { +<<<<<<< HEAD + "version": "0.1.51", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.51.tgz", + "integrity": "sha512-ktR3u64NPjwIViNCck+z9QeyN0iPkQCUOQ07ZCV1RzlkfP+olLTeEZ95O1QHS+v4w9vJeY9xj/uJuSphsHy5rQ==", +======= "version": "0.1.50", "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.50.tgz", "integrity": "sha512-GjG3CQV7SyWk/lEXqFPuKchRPHIBbD317Gj8NUqqB+UOnQlOYtjGLCTRIWzO9Ta698LVzlBCSE9XKqBSWpIDmg==", +>>>>>>> 8a80203467ffcb3f87bb6a7f74655a6e1043d051 "dev": true }, "abbrev": { diff --git a/package.json b/package.json index c7331d241d12..cef3de27ed1d 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/w3c-image-capture": "^1.0.10", "@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/parser": "^6.9.1", - "@webgpu/types": "^0.1.50", + "@webgpu/types": "^0.1.51", "ansi-colors": "4.1.3", "babel-plugin-add-header-comment": "^1.0.3", "babel-plugin-const-enum": "^1.2.0", diff --git a/src/webgpu/api/operation/adapter/info.spec.ts b/src/webgpu/api/operation/adapter/info.spec.ts index ee5c4e86c57f..89dbbaa621f2 100644 --- a/src/webgpu/api/operation/adapter/info.spec.ts +++ b/src/webgpu/api/operation/adapter/info.spec.ts @@ -1,11 +1,12 @@ export const description = ` -Tests GPUAdapter.info members formatting. +Tests for GPUAdapterInfo. `; import { Fixture } from '../../../../common/framework/fixture.js'; import { makeTestGroup } from '../../../../common/framework/test_group.js'; +import { keysOf } from '../../../../common/util/data_tables.js'; import { getGPU } from '../../../../common/util/navigator_gpu.js'; -import { assert } from '../../../../common/util/util.js'; +import { assert, objectEquals } from '../../../../common/util/util.js'; export const g = makeTestGroup(Fixture); @@ -39,3 +40,97 @@ g.test('adapter_info') `adapterInfo.device should be a normalized identifier. But it's '${adapterInfo.device}'` ); }); + +g.test('same_object') + .desc( + ` +GPUAdapter.info and GPUDevice.adapterInfo provide the same object each time they're accessed, +but different objects from one another.` + ) + .fn(async t => { + const gpu = getGPU(t.rec); + const adapter = await gpu.requestAdapter(); + assert(adapter !== null); + + const adapterInfo1 = adapter.info; + const adapterInfo2 = adapter.info; + t.expect(adapterInfo1 === adapterInfo2, 'adapter.info should obey [SameObject]'); + + const device = await t.requestDeviceTracked(adapter); + assert(device !== null); + + const deviceAdapterInfo1 = device.adapterInfo; + const deviceAdapterInfo2 = device.adapterInfo; + t.expect( + deviceAdapterInfo1 === deviceAdapterInfo2, + 'device.adapterInfo should obey [SameObject]' + ); + + t.expect( + adapter.info !== device.adapterInfo, + 'adapter.info and device.adapterInfo should NOT return the same object' + ); + }); + +g.test('device_matches_adapter') + .desc( + ` +Test that GPUDevice.adapterInfo matches GPUAdapter.info. Cases access the members in +different orders to make sure that they are consistent regardless of the access order.` + ) + .paramsSubcasesOnly(u => + u.combine('testDeviceFirst', [true, false]).combine('testMembersFirst', [true, false]) + ) + .fn(async t => { + const { testDeviceFirst, testMembersFirst } = t.params; + + const gpu = getGPU(t.rec); + const adapter = await gpu.requestAdapter(); + assert(adapter !== null); + + const device = await t.requestDeviceTracked(adapter); + assert(device !== null); + + const deviceInfo: unknown[] = []; + const adapterInfo: unknown[] = []; + + const kGPUAdapterInfoKeys = keysOf(GPUAdapterInfo.prototype); + if (testMembersFirst) { + if (testDeviceFirst) { + assert(device.adapterInfo instanceof GPUAdapterInfo); + for (const k of kGPUAdapterInfoKeys) { + deviceInfo.push(device.adapterInfo[k]); + } + assert(adapter.info instanceof GPUAdapterInfo); + for (const k of kGPUAdapterInfoKeys) { + adapterInfo.push(adapter.info[k]); + } + } else { + assert(adapter.info instanceof GPUAdapterInfo); + for (const k of kGPUAdapterInfoKeys) { + adapterInfo.push(adapter.info[k]); + } + assert(device.adapterInfo instanceof GPUAdapterInfo); + for (const k of kGPUAdapterInfoKeys) { + deviceInfo.push(device.adapterInfo[k]); + } + } + } else { + if (testDeviceFirst) { + assert(device.adapterInfo instanceof GPUAdapterInfo); + assert(adapter.info instanceof GPUAdapterInfo); + for (const k of kGPUAdapterInfoKeys) { + deviceInfo.push(device.adapterInfo[k]); + adapterInfo.push(adapter.info[k]); + } + } else { + assert(adapter.info instanceof GPUAdapterInfo); + assert(device.adapterInfo instanceof GPUAdapterInfo); + for (const k of kGPUAdapterInfoKeys) { + adapterInfo.push(adapter.info[k]); + deviceInfo.push(device.adapterInfo[k]); + } + } + t.expect(objectEquals(deviceInfo, adapterInfo)); + } + });