From bbefe4def10c6f5c7f2b4bcf4bb5399343f31523 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 13 Mar 2025 08:40:18 -0700 Subject: [PATCH] Reset CPU buffer in compute shader in additioa to resetting GPU buffer on each dispatch. --- src/classes/gpu.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/classes/gpu.ts b/src/classes/gpu.ts index 44e52c1..a23b900 100644 --- a/src/classes/gpu.ts +++ b/src/classes/gpu.ts @@ -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({ -- 2.34.1