Last active
July 24, 2025 19:09
-
-
Save greggman/89c0411946f59b8ccdfafc89b295b049 to your computer and use it in GitHub Desktop.
WebGPU: Check how many QuerySets we can have
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*bug-in-github-api-content-can-not-be-empty*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*bug-in-github-api-content-can-not-be-empty*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function main () { | |
const adapter = await navigator.gpu.requestAdapter(); | |
if (!adapter.features.has('timestamp-query')) { | |
console.error('need timestamp-query'); | |
return; | |
} | |
const device = await adapter.requestDevice({ requiredFeatures: ['timestamp-query'] }); | |
const queries = []; | |
for (;;) { | |
device.pushErrorScope('validation'); | |
const querySet = device.createQuerySet({ type: 'timestamp', count: 2, label: `QuerySet#${queries.length + 1} ` }); | |
queries.push(querySet); | |
device.queue.submit([]); | |
{ | |
const err = await device.popErrorScope(); | |
if (err) { | |
console.error('at creation:', err.message); | |
break; | |
} | |
} | |
device.pushErrorScope('validation'); | |
const encoder = device.createCommandEncoder(); | |
const pass = encoder.beginComputePass({ | |
timestampWrites: { | |
querySet, | |
beginningOfPassWriteIndex: 0, | |
gendOfPassWriteIndex: 1, | |
}, | |
}); | |
pass.end(); | |
device.queue.submit([encoder.finish()]); | |
{ | |
const err = await device.popErrorScope(); | |
if (err) { | |
console.error('at usage:', err.message); | |
break; | |
} | |
} | |
if (queries.length % 100 === 0) { | |
console.log(queries.length); | |
await new Promise(resolve => setTimeout(resolve, 100)); | |
} | |
} | |
console.log('num queries:', queries.length - 1); | |
} | |
main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"name":"WebGPU: Check how many QuerySets we can have","settings":{},"filenames":["index.html","index.css","index.js"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment