diff --git a/both_webgpu/both.mjs b/both_webgpu/both.mjs index caffc10..fb2a684 100644 --- a/both_webgpu/both.mjs +++ b/both_webgpu/both.mjs @@ -1,4 +1,4 @@ -import { greeting } from "./greeting.mjs"; +import { platform } from "./platform.mjs"; async function getDeviceAndAdapter(navigator) { const adapter = await navigator.gpu.requestAdapter(); @@ -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]) { diff --git a/both_webgpu/platform.mjs b/both_webgpu/platform.mjs new file mode 100644 index 0000000..5d5116a --- /dev/null +++ b/both_webgpu/platform.mjs @@ -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 };