From 7fb1b2b439f16b40a142c24b4a0665fd13839a55 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 21 Jan 2025 09:08:11 -0800 Subject: [PATCH] Reduce loop iteration by reading 64 bits at a time into UBO. --- src/classes/gpu.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/classes/gpu.ts b/src/classes/gpu.ts index caf2ad1..8fb469a 100644 --- a/src/classes/gpu.ts +++ b/src/classes/gpu.ts @@ -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) -- 2.34.1