Skip to content

Commit

Permalink
doing a standalone query-set test
Browse files Browse the repository at this point in the history
  • Loading branch information
John Owens committed Nov 6, 2024
1 parent d12bd2d commit d63e071
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
31 changes: 31 additions & 0 deletions deno-query-set.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
async function main(navigator) {
const adapter = await navigator.gpu?.requestAdapter();
const canTimestamp = adapter.features.has("timestamp-query");
const device = await adapter?.requestDevice({
requiredFeatures: [...(canTimestamp ? ["timestamp-query"] : [])],
});

if (!device) {
fail("Fatal error: Device does not support WebGPU.");
}

if (!canTimestamp) {
fail(
'Fatal error: Device does not support WebGPU timestamp query (`adapter.features.has("timestamp-query")` is false).'
);
}

const querySet = device.createQuerySet({
type: "timestamp",
count: 2,
});

console.log(querySet);

function fail(msg) {
// eslint-disable-next-line no-alert
alert(msg);
}
}

await main(navigator);
14 changes: 14 additions & 0 deletions query-set.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>Testing Query Set</title>
</head>

<body>
<div id="plot"></div>
<script src="http://localhost:8000/webgpu-sandbox/deno-query-set.mjs" type="module"></script>
</script>
</body>
</html>

0 comments on commit d63e071

Please sign in to comment.