Skip to content

Commit

Permalink
now prints platform at start; works on Chrome, Node, Deno
Browse files Browse the repository at this point in the history
  • Loading branch information
John Owens committed Nov 6, 2024
1 parent 341c4eb commit 9c59483
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 2 additions & 8 deletions both_webgpu/both.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { greeting } from "./greeting.mjs";
import { platform } from "./platform.mjs";

async function getDeviceAndAdapter(navigator) {
const adapter = await navigator.gpu.requestAdapter();
Expand All @@ -22,13 +22,7 @@ async function main(navigator) {
if (!device) {
throw new Error("Fatal error: Device does not support WebGPU.");
}
console.log("I am main! (WebGPU)");
if (typeof process !== "undefined") {
console.log(" Process release name:", process.release.name);
} else {
console.log(" I'm probably running in a web browser.");
}
greeting();
console.log(`WebGPU is ${platform(navigator)}`);

const data = [];
for (const workgroupSize of [32, 64, 128]) {
Expand Down
12 changes: 12 additions & 0 deletions both_webgpu/platform.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function platform(navigator) {
if (typeof process !== "undefined") {
if (navigator.userAgent?.startsWith("Deno")) {
return navigator.userAgent;
} else {
return process.release.name;
}
} else {
return navigator.userAgent;
}
}
export { platform };

0 comments on commit 9c59483

Please sign in to comment.