]> zoso.dev Git - nano-pow.git/commitdiff
Initial attempt at creating fallback to GL.
authorChris Duncan <chris@zoso.dev>
Sun, 12 Jan 2025 08:36:10 +0000 (00:36 -0800)
committerChris Duncan <chris@zoso.dev>
Sun, 12 Jan 2025 08:36:10 +0000 (00:36 -0800)
src/classes/gpu.ts
src/classes/index.ts
test.html

index 6da73960fa6a9604149db84f90042df7ff5d4c81..c8de386cdb51f42fc6f7cf517a7ffec6a07fdb91 100644 (file)
@@ -18,9 +18,9 @@ export class NanoPowGpu {
        static #bindGroupLayout: GPUBindGroupLayout
        static #pipeline: GPUComputePipeline
 
-       static {
-               this.init()
-       }
+       // static {
+       //      this.init()
+       // }
 
        // Initialize WebGPU
        static async init (): Promise<void> {
index 525577e35632f2f4cc3ec0eba692f2662e4ecbbd..b5330eee5c0857728566f2598049cf6241c26dac 100644 (file)
@@ -2,9 +2,13 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
 
 import { NanoPowGl } from "./gl.js"
-import { NanoPowGpu } from "./gpu.js"
-
-export {
-       NanoPowGl,
-       NanoPowGpu
+import { NanoPowGpu as gpu } from "./gpu.js"
+console.log(`export barrel`)
+let NanoPowGpu = null
+try {
+       NanoPowGpu = await gpu.init()
+} catch (err) {
+       console.warn(`WebGPU is not supported in this environment.`)
 }
+console.log(`barrel`)
+export { NanoPowGl, NanoPowGpu }
index de8bdae9632607b25584343d1799ce1628138973..d395eee82fe9e9f7460cfc06421f144998478c21 100644 (file)
--- a/test.html
+++ b/test.html
@@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
        <link rel="icon" href="./favicon.ico">
        <script type="module" src="../dist/global.min.js"></script>
        <!-- Comment out nano-pow from CDN if testing locally -->
-       <script type="module" src="https://cdn.jsdelivr.net/npm/nano-pow@1.1.0/dist/global.min.js"></script>
+       <!-- <script type="module" src="https://cdn.jsdelivr.net/npm/nano-pow@1.1.0/dist/global.min.js"></script> -->
        <script type="module" src="https://cdn.jsdelivr.net/npm/nano-webgl-pow@1.1.1/nano-webgl-pow.js"></script>
        <script type="module">
                const { NanoPowGl, NanoPowGpu } = NanoPow