|
| 1 | +export const description = ` |
| 2 | +API operations tests for timestamp queries. |
| 3 | +
|
| 4 | +Given the values returned are implementation defined |
| 5 | +there is not much we can test except that there are no errors. |
| 6 | +
|
| 7 | +- test query with |
| 8 | + - compute pass |
| 9 | + - render pass |
| 10 | + - 64k query objects |
| 11 | +`; |
| 12 | + |
| 13 | +import { makeTestGroup } from '../../../../../common/framework/test_group.js'; |
| 14 | +import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js'; |
| 15 | + |
| 16 | +export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest); |
| 17 | + |
| 18 | +g.test('many') |
| 19 | + .desc( |
| 20 | + ` |
| 21 | +Test creating and using 64k query objects. |
| 22 | +
|
| 23 | +This test is because there is a Metal limit of 32 timestamp query sets. |
| 24 | +Implementations are supposed to work around this limit by internally allocating |
| 25 | +larger metal sets and having the WebGPU sets be subsets of those larger sets. |
| 26 | +
|
| 27 | +This is particular important as the limit is 32 per process |
| 28 | +so a few pages making a few queries would easily hit the limit |
| 29 | +and prevent pages from running. |
| 30 | + ` |
| 31 | + ) |
| 32 | + .params(u => u |
| 33 | + .combine('numQuerySets', [8, 16, 32, 64, 256, 65536] as const) |
| 34 | + .combine('stage', ['compute', 'render'] as const) |
| 35 | + ) |
| 36 | + .fn(t => { |
| 37 | + const { stage, numQuerySets } = t.params; |
| 38 | + |
| 39 | + t.skipIfDeviceDoesNotHaveFeature('timestamp-query'); |
| 40 | + |
| 41 | + const view = t |
| 42 | + .createTextureTracked({ |
| 43 | + size: [1, 1, 1], |
| 44 | + format: 'rgba8unorm', |
| 45 | + usage: GPUTextureUsage.RENDER_ATTACHMENT, |
| 46 | + }) |
| 47 | + .createView(); |
| 48 | + const encoder = t.device.createCommandEncoder(); |
| 49 | + |
| 50 | + for (let i = 0; i < numQuerySets; ++i) { |
| 51 | + const querySet = t.createQuerySetTracked({ |
| 52 | + type: 'timestamp', |
| 53 | + count: 2, |
| 54 | + }); |
| 55 | + |
| 56 | + switch (stage) { |
| 57 | + case 'compute': { |
| 58 | + const pass = encoder.beginComputePass({ |
| 59 | + timestampWrites: { |
| 60 | + querySet, |
| 61 | + beginningOfPassWriteIndex: 0, |
| 62 | + endOfPassWriteIndex: 1, |
| 63 | + }, |
| 64 | + }); |
| 65 | + pass.end(); |
| 66 | + break; |
| 67 | + } |
| 68 | + case 'render': { |
| 69 | + const pass = encoder.beginRenderPass({ |
| 70 | + colorAttachments: [{ view, loadOp: 'load', storeOp: 'store' }], |
| 71 | + timestampWrites: { |
| 72 | + querySet, |
| 73 | + beginningOfPassWriteIndex: 0, |
| 74 | + endOfPassWriteIndex: 1, |
| 75 | + }, |
| 76 | + }); |
| 77 | + pass.end(); |
| 78 | + break; |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + const shouldError = false; // just expect no error |
| 84 | + t.expectValidationError(() => t.device.queue.submit([encoder.finish()]), shouldError); |
| 85 | + }); |
0 commit comments