From 7dda75f0afc05006439ceabfa58e8da231a848c0 Mon Sep 17 00:00:00 2001 From: Hao Li Date: Tue, 21 Nov 2023 17:10:38 +0800 Subject: [PATCH] Ignore compilation error in writeTimestamp tests (#3177) * 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 --- .../features/query_types.spec.ts | 3 +- .../encoding/encoder_open_state.spec.ts | 8 ++- .../encoding/queries/general.spec.ts | 17 +++--- .../queue/destroyed/query_set.spec.ts | 53 ++++++++++++++++--- .../state/device_lost/destroy.spec.ts | 3 +- src/webgpu/listing_meta.json | 2 +- 6 files changed, 66 insertions(+), 20 deletions(-) diff --git a/src/webgpu/api/validation/capability_checks/features/query_types.spec.ts b/src/webgpu/api/validation/capability_checks/features/query_types.spec.ts index f045848fb0bb..9d6ab1cdcee5 100644 --- a/src/webgpu/api/validation/capability_checks/features/query_types.spec.ts +++ b/src/webgpu/api/validation/capability_checks/features/query_types.spec.ts @@ -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(); } diff --git a/src/webgpu/api/validation/encoding/encoder_open_state.spec.ts b/src/webgpu/api/validation/encoding/encoder_open_state.spec.ts index 66a00b2c3bf4..815ca5a198bc 100644 --- a/src/webgpu/api/validation/encoding/encoder_open_state.spec.ts +++ b/src/webgpu/api/validation/encoding/encoder_open_state.spec.ts @@ -57,7 +57,10 @@ class F extends ValidationTest { export const g = makeTestGroup(F); -type EncoderCommands = keyof Omit; +// MAINTENANCE_TODO: Remove writeTimestamp from here once it's (hopefully) added back to the spec. +type EncoderCommands = + | keyof Omit + | 'writeTimestamp'; const kEncoderCommandInfo: { readonly [k in EncoderCommands]: {}; } = { @@ -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'); } diff --git a/src/webgpu/api/validation/encoding/queries/general.spec.ts b/src/webgpu/api/validation/encoding/queries/general.spec.ts index e529c3b5ff67..8c9c4bb55181 100644 --- a/src/webgpu/api/validation/encoding/queries/general.spec.ts +++ b/src/webgpu/api/validation/encoding/queries/general.spec.ts @@ -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 @@ -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'); } @@ -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 => { @@ -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'); } @@ -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'); } diff --git a/src/webgpu/api/validation/queue/destroyed/query_set.spec.ts b/src/webgpu/api/validation/queue/destroyed/query_set.spec.ts index b091e4855f59..987a88830ddf 100644 --- a/src/webgpu/api/validation/queue/destroyed/query_set.spec.ts +++ b/src/webgpu/api/validation/queue/destroyed/query_set.spec.ts @@ -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. @@ -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') diff --git a/src/webgpu/api/validation/state/device_lost/destroy.spec.ts b/src/webgpu/api/validation/state/device_lost/destroy.spec.ts index 56d53c98676c..a9e5a7f91a90 100644 --- a/src/webgpu/api/validation/state/device_lost/destroy.spec.ts +++ b/src/webgpu/api/validation/state/device_lost/destroy.spec.ts @@ -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'); } diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index e4e3e6bad37f..c6d8415388d8 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -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 },