-
Notifications
You must be signed in to change notification settings - Fork 95
Add tests for GPUDevice.adapterInfo #4023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
b5c735a
5b2d7b4
5a23afd
d578f69
b45e663
24a4f41
90d9beb
519ea90
bc7b56b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
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 { 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 +39,42 @@ g.test('adapter_info') | |
`adapterInfo.device should be a normalized identifier. But it's '${adapterInfo.device}'` | ||
); | ||
}); | ||
|
||
g.test('same_object') | ||
.desc( | ||
` | ||
GPUAdapter.info provides the same object each time it's accessed` | ||
) | ||
.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); | ||
}); | ||
|
||
g.test('device_matches_adapter') | ||
.desc( | ||
` | ||
Test that GPUDevice.adapterInfo matches GPUAdapter.info` | ||
kainino0x marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
.fn(async t => { | ||
const gpu = getGPU(t.rec); | ||
const adapter = await gpu.requestAdapter(); | ||
assert(adapter !== null); | ||
|
||
const device = await t.requestDeviceTracked(adapter); | ||
assert(device !== null); | ||
|
||
assert(device.adapterInfo instanceof GPUAdapterInfo); | ||
assert(adapter.info instanceof GPUAdapterInfo); | ||
|
||
for (const k of Object.keys(GPUAdapterInfo.prototype)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Landed the spec; didn't make adapter and device use the same object, so we should test that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spec doesn't say they have to be different object, so I wouldn't test that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does implicitly require them to be different objects, because a new one is created the first time each of them is accessed, there's no opportunity to return the same one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should construct the |
||
t.expect( | ||
objectEquals(device.adapterInfo[k], adapter.info[k]), | ||
kainino0x marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`device.adapterInfo.${k} is "${device.adapterInfo[k]}". Expected "${adapter.info[k]}"` | ||
); | ||
} | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.