]> git.codecow.com Git - nano-pow.git/commitdiff
Only run self-check once per API per page load.
authorChris Duncan <chris@codecow.com>
Sun, 26 Jul 2026 09:23:31 +0000 (02:23 -0700)
committerChris Duncan <chris@codecow.com>
Tue, 28 Jul 2026 05:24:28 +0000 (22:24 -0700)
index.html

index 468c7ac5796afbb1bd7b9cf0f97268294c80b653..bdffb28211108caff73da3ff5624d0b9d4d3ed8e 100644 (file)
@@ -31,6 +31,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
                        document.getElementById('status').textContent = `READY`
                }
 
+               const selfChecked = {
+                       webgpu: false,
+                       webgl: false,
+                       wasm: false,
+                       cpu: false
+               }
+
                const logger = new Logger()
 
                const glSize = (canvas => {
@@ -105,7 +112,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
                 * @param {string} api
                 */
                async function selfCheck (api) {
-                       document.getElementById('status').textContent = `RUNNING SELF-CHECK`
+                       if (selfChecked[api]) return
+                       document.getElementById('status').textContent = `RUNNING SELF-CHECK: ${api.toUpperCase()}`
                        logger.log(`%cNanoPow`, 'color:green', 'Checking validation against known values')
                        const options = { api, debug: true }
                        // Generate once on load to compile shaders and initialize buffers
@@ -195,7 +203,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
                                expect.push(isValid)
                        }
 
-                       if (!expect.every(result => result)) {
+                       if (expect.every(result => result)) {
+                               selfChecked[api] = true
+                       } else {
                                document.getElementById('status').textContent = `FAILED TO VALIDATE KNOWN VALUES, CHECK CONSOLE`
                                throw new Error(`Validation is not working`)
                        }