]> zoso.dev Git - nano-pow.git/commitdiff
Reduce loop iteration by reading 64 bits at a time into UBO.
authorChris Duncan <chris@zoso.dev>
Tue, 21 Jan 2025 17:08:11 +0000 (09:08 -0800)
committerChris Duncan <chris@zoso.dev>
Tue, 21 Jan 2025 17:08:11 +0000 (09:08 -0800)
src/classes/gpu.ts

index caf2ad16058cd76c23f63c51ca80a9d1a4b20efe..8fb469a30b02e801f9939ab66587c42a11eda04c 100644 (file)
@@ -134,9 +134,9 @@ export class NanoPowGpu {
                // Set up uniform buffer object
                // Note: u32 size is 4, but total alignment must be multiple of 16
                const uboView = new DataView(new ArrayBuffer(48))
-               for (let i = 0; i < 64; i += 8) {
-                       const uint32 = hash.slice(i, i + 8)
-                       uboView.setUint32(i / 2, parseInt(uint32, 16))
+               for (let i = 0; i < 64; i += 16) {
+                       const u64 = hash.slice(i, i + 16)
+                       uboView.setBigUint64(i / 2, BigInt(`0x${u64}`))
                }
                uboView.setBigUint64(32, seed, true)
                uboView.setUint32(40, threshold, true)