Skip to content

Commit

Permalink
Ignore compilation error in writeTimestamp tests (#3177)
Browse files Browse the repository at this point in the history
* Ignore compilation error in writeTimestamp tests

As writeTimestamp API has been removed from SPEC and webgpu types, the
tests including it will cause build error when rolling latest types.

Remove the related cases or update to use pass's timestampWrites
instead.

* ignore compile error instead of removing tests

* format TODO

* Use 'as any' over ts-ignore, remove need for other 'as any's

---------

Co-authored-by: Kai Ninomiya <[email protected]>
  • Loading branch information
haoxli and kainino0x authored Nov 21, 2023
1 parent 300768e commit 7dda75f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ g.test('timestamp')

const encoder = t.createEncoder('non-pass');
t.shouldThrow(expected, () => {
encoder.encoder.writeTimestamp(querySet, 0);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(encoder.encoder as any).writeTimestamp(querySet, 0);
});
encoder.finish();
}
Expand Down
8 changes: 6 additions & 2 deletions src/webgpu/api/validation/encoding/encoder_open_state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class F extends ValidationTest {

export const g = makeTestGroup(F);

type EncoderCommands = keyof Omit<GPUCommandEncoder, '__brand' | 'label' | 'finish'>;
// MAINTENANCE_TODO: Remove writeTimestamp from here once it's (hopefully) added back to the spec.
type EncoderCommands =
| keyof Omit<GPUCommandEncoder, '__brand' | 'label' | 'finish'>
| 'writeTimestamp';
const kEncoderCommandInfo: {
readonly [k in EncoderCommands]: {};
} = {
Expand Down Expand Up @@ -263,7 +266,8 @@ g.test('non_pass_commands')
break;
case 'writeTimestamp':
try {
encoder.writeTimestamp(querySet, 0);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(encoder as any).writeTimestamp(querySet, 0);
} catch (ex) {
t.skipIf(ex instanceof TypeError, 'writeTimestamp is actually not available');
}
Expand Down
17 changes: 10 additions & 7 deletions src/webgpu/api/validation/encoding/queries/general.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ Tests that write timestamp to all types of query set on all possible encoders:
- queryIndex {in, out of} range for GPUQuerySet
- x= {non-pass} encoder
TODO: writeTimestamp is removed from the spec so it's skipped if it TypeErrors.
`
TODO: writeTimestamp is removed from the spec so it's skipped if it TypeErrors.
`
)
.params(u =>
u
Expand All @@ -104,7 +104,8 @@ Tests that write timestamp to all types of query set on all possible encoders:

const encoder = t.createEncoder('non-pass');
try {
encoder.encoder.writeTimestamp(querySet, queryIndex);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(encoder.encoder as any).writeTimestamp(querySet, queryIndex);
} catch (ex) {
t.skipIf(ex instanceof TypeError, 'writeTimestamp is actually not available');
}
Expand All @@ -117,8 +118,8 @@ g.test('writeTimestamp,invalid_query_set')
Tests that write timestamp to a invalid query set that failed during creation:
- x= {non-pass} encoder
TODO: writeTimestamp is removed from the spec so it's skipped if it TypeErrors.
`
TODO: writeTimestamp is removed from the spec so it's skipped if it TypeErrors.
`
)
.paramsSubcasesOnly(u => u.combine('querySetState', ['valid', 'invalid'] as const))
.beforeAllSubcases(t => {
Expand All @@ -134,7 +135,8 @@ Tests that write timestamp to a invalid query set that failed during creation:

const encoder = t.createEncoder('non-pass');
try {
encoder.encoder.writeTimestamp(querySet, 0);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(encoder.encoder as any).writeTimestamp(querySet, 0);
} catch (ex) {
t.skipIf(ex instanceof TypeError, 'writeTimestamp is actually not available');
}
Expand Down Expand Up @@ -165,7 +167,8 @@ g.test('writeTimestamp,device_mismatch')

const encoder = t.createEncoder('non-pass');
try {
encoder.encoder.writeTimestamp(querySet, 0);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(encoder.encoder as any).writeTimestamp(querySet, 0);
} catch (ex) {
t.skipIf(ex instanceof TypeError, 'writeTimestamp is actually not available');
}
Expand Down
53 changes: 45 additions & 8 deletions src/webgpu/api/validation/queue/destroyed/query_set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Tests that use a destroyed query set in occlusion query on render pass encoder.
encoder.validateFinishAndSubmitGivenState(t.params.querySetState);
});

g.test('writeTimestamp')
g.test('timestamps')
.desc(
`
Tests that use a destroyed query set in writeTimestamp on {non-pass, compute, render} encoder.
Tests that use a destroyed query set in timestamp query on {non-pass, compute, render} encoder.
- x= {destroyed, not destroyed (control case)}
TODO: writeTimestamp is removed from the spec so it's skipped if it TypeErrors.
Expand All @@ -41,13 +41,50 @@ Tests that use a destroyed query set in writeTimestamp on {non-pass, compute, re
count: 2,
});

const encoder = t.createEncoder('non-pass');
try {
encoder.encoder.writeTimestamp(querySet, 0);
} catch (ex) {
t.skipIf(ex instanceof TypeError, 'writeTimestamp is actually not available');
{
const encoder = t.createEncoder('non-pass');
try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(encoder.encoder as any).writeTimestamp(querySet, 0);
} catch (ex) {
t.skipIf(ex instanceof TypeError, 'writeTimestamp is actually not available');
}
encoder.validateFinishAndSubmitGivenState(t.params.querySetState);
}

{
const encoder = t.createEncoder('non-pass');
encoder.encoder
.beginComputePass({
timestampWrites: { querySet, beginningOfPassWriteIndex: 0 },
})
.end();
encoder.validateFinishAndSubmitGivenState(t.params.querySetState);
}

{
const texture = t.trackForCleanup(
t.device.createTexture({
size: [1, 1, 1],
format: 'rgba8unorm',
usage: GPUTextureUsage.RENDER_ATTACHMENT,
})
);
const encoder = t.createEncoder('non-pass');
encoder.encoder
.beginRenderPass({
colorAttachments: [
{
view: texture.createView(),
loadOp: 'load',
storeOp: 'store',
},
],
timestampWrites: { querySet, beginningOfPassWriteIndex: 0 },
})
.end();
encoder.validateFinishAndSubmitGivenState(t.params.querySetState);
}
encoder.validateFinishAndSubmitGivenState(t.params.querySetState);
});

g.test('resolveQuerySet')
Expand Down
3 changes: 2 additions & 1 deletion src/webgpu/api/validation/state/device_lost/destroy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,8 @@ Tests encoding and finishing a writeTimestamp command on destroyed device.
const querySet = t.device.createQuerySet({ type, count: 2 });
await t.executeCommandsAfterDestroy(stage, awaitLost, 'non-pass', maker => {
try {
maker.encoder.writeTimestamp(querySet, 0);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(maker.encoder as any).writeTimestamp(querySet, 0);
} catch (ex) {
t.skipIf(ex instanceof TypeError, 'writeTimestamp is actually not available');
}
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@
"webgpu:api,validation,queue,destroyed,buffer:writeBuffer:*": { "subcaseMS": 2.151 },
"webgpu:api,validation,queue,destroyed,query_set:beginOcclusionQuery:*": { "subcaseMS": 17.401 },
"webgpu:api,validation,queue,destroyed,query_set:resolveQuerySet:*": { "subcaseMS": 16.401 },
"webgpu:api,validation,queue,destroyed,query_set:writeTimestamp:*": { "subcaseMS": 0.901 },
"webgpu:api,validation,queue,destroyed,query_set:timestamps:*": { "subcaseMS": 0.901 },
"webgpu:api,validation,queue,destroyed,texture:beginRenderPass:*": { "subcaseMS": 0.350 },
"webgpu:api,validation,queue,destroyed,texture:copyBufferToTexture:*": { "subcaseMS": 16.550 },
"webgpu:api,validation,queue,destroyed,texture:copyTextureToBuffer:*": { "subcaseMS": 15.900 },
Expand Down

0 comments on commit 7dda75f

Please sign in to comment.