]> zoso.dev Git - nano-pow.git/commitdiff
Reset CPU buffer in compute shader in additioa to resetting GPU buffer on each dispatch.
authorChris Duncan <chris@zoso.dev>
Thu, 13 Mar 2025 15:40:18 +0000 (08:40 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 13 Mar 2025 15:40:18 +0000 (08:40 -0700)
src/classes/gpu.ts

index 44e52c1845e4c0d5928f14d8e58cbd46851a5908..a23b900c867543ad3bc34bae2635f420763b40a1 100644 (file)
@@ -13,7 +13,7 @@ export class NanoPowGpu {
        static #busy: boolean = false
        static #debug: boolean = false
        static #device: GPUDevice | null = null
-       static #gpuBufferReset: BigUint64Array = new BigUint64Array([0n, 0n])
+       static #bufferReset: BigUint64Array = new BigUint64Array([0n, 0n, 0n, 0n])
        static #gpuBuffer: GPUBuffer
        static #cpuBuffer: GPUBuffer
        static #uboBuffer: GPUBuffer
@@ -155,8 +155,9 @@ export class NanoPowGpu {
                if (this.#debug) console.log('UBO', this.#uboView)
                this.#device.queue.writeBuffer(this.#uboBuffer, 0, this.#uboView)
 
-               // Reset `nonce` and `found` to 0u in WORK before each calculation
-               this.#device.queue.writeBuffer(this.#gpuBuffer, 0, this.#gpuBufferReset)
+               // Reset WORK properties to 0u before each calculation
+               this.#device.queue.writeBuffer(this.#gpuBuffer, 0, this.#bufferReset)
+               this.#device.queue.writeBuffer(this.#cpuBuffer, 0, this.#bufferReset)
 
                // Bind UBO read and GPU write buffers
                const bindGroup = this.#device.createBindGroup({