Skip to content

Commit f9e7872

Browse files
haoxlikainino0x
andauthored
Allow tests to extend endTestScope timeout (#4560)
* Allow tests to extend endTestScope timeout Added a per-test endTestScope timeout function so heavy cases can extend the time without slowing down the rest of the suite, and used it to give the 64K timestamp-query stress test run extra headroom, avoiding flakes while leaving the default 5000ms limit untouched elsewhere. * Wrap the test body with pushErrorScope and popErrorScope * review nits --------- Co-authored-by: Kai Ninomiya <kainino@chromium.org>
1 parent 68544fd commit f9e7872

1 file changed

Lines changed: 51 additions & 42 deletions

File tree

src/webgpu/api/operation/command_buffer/queries/timestampQuery.spec.ts

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,55 +35,64 @@ and prevent pages from running.
3535
.combine('numQuerySets', [8, 16, 32, 64, 256, 65536] as const)
3636
.combine('stage', ['compute', 'render'] as const)
3737
)
38-
.fn(t => {
38+
.fn(async t => {
3939
const { stage, numQuerySets } = t.params;
4040

4141
t.skipIfDeviceDoesNotHaveFeature('timestamp-query');
4242

43-
const view = t
44-
.createTextureTracked({
45-
size: [1, 1, 1],
46-
format: 'rgba8unorm',
47-
usage: GPUTextureUsage.RENDER_ATTACHMENT,
48-
})
49-
.createView();
50-
const encoder = t.device.createCommandEncoder();
51-
52-
for (let i = 0; i < numQuerySets; ++i) {
53-
const querySet = t.createQuerySetTracked({
54-
type: 'timestamp',
55-
count: 2,
56-
});
57-
58-
switch (stage) {
59-
case 'compute': {
60-
const pass = encoder.beginComputePass({
61-
timestampWrites: {
62-
querySet,
63-
beginningOfPassWriteIndex: 0,
64-
endOfPassWriteIndex: 1,
65-
},
66-
});
67-
pass.end();
68-
break;
69-
}
70-
case 'render': {
71-
const pass = encoder.beginRenderPass({
72-
colorAttachments: [{ view, loadOp: 'load', storeOp: 'store' }],
73-
timestampWrites: {
74-
querySet,
75-
beginningOfPassWriteIndex: 0,
76-
endOfPassWriteIndex: 1,
77-
},
78-
});
79-
pass.end();
80-
break;
43+
// At large numQuerySets, this test incurs a lot of validation, which can take several seconds.
44+
// Explicitly wrap the test in its own error scope to avoid triggering timeouts in test-cleanup.
45+
t.device.pushErrorScope('validation');
46+
try {
47+
const view = t
48+
.createTextureTracked({
49+
size: [1, 1, 1],
50+
format: 'rgba8unorm',
51+
usage: GPUTextureUsage.RENDER_ATTACHMENT,
52+
})
53+
.createView();
54+
const encoder = t.device.createCommandEncoder();
55+
56+
for (let i = 0; i < numQuerySets; ++i) {
57+
const querySet = t.createQuerySetTracked({
58+
type: 'timestamp',
59+
count: 2,
60+
});
61+
62+
switch (stage) {
63+
case 'compute': {
64+
const pass = encoder.beginComputePass({
65+
timestampWrites: {
66+
querySet,
67+
beginningOfPassWriteIndex: 0,
68+
endOfPassWriteIndex: 1,
69+
},
70+
});
71+
pass.end();
72+
break;
73+
}
74+
case 'render': {
75+
const pass = encoder.beginRenderPass({
76+
colorAttachments: [{ view, loadOp: 'load', storeOp: 'store' }],
77+
timestampWrites: {
78+
querySet,
79+
beginningOfPassWriteIndex: 0,
80+
endOfPassWriteIndex: 1,
81+
},
82+
});
83+
pass.end();
84+
break;
85+
}
8186
}
8287
}
83-
}
8488

85-
const shouldError = false; // just expect no error
86-
t.expectValidationError(() => t.device.queue.submit([encoder.finish()]), shouldError);
89+
const shouldError = false; // just expect no error
90+
t.expectValidationError(() => t.device.queue.submit([encoder.finish()]), shouldError);
91+
} finally {
92+
const error = await t.device.popErrorScope();
93+
// Make sure there weren't any unexpected validation errors caught by the scope.
94+
t.expect(error === null, error?.message);
95+
}
8796
});
8897

8998
g.test('many_slots')

0 commit comments

Comments
 (0)