From 0ccfd7b8c4b9c58d3b6e750854e3b3c9c25cb6c6 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 4 Jan 2025 04:00:48 -0800 Subject: [PATCH] Reset `found` flag between executions. --- src/lib/workers/powgpu.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/workers/powgpu.ts b/src/lib/workers/powgpu.ts index d842215..dedfb79 100644 --- a/src/lib/workers/powgpu.ts +++ b/src/lib/workers/powgpu.ts @@ -306,6 +306,7 @@ export class PowGpu extends WorkerInterface { return } + // 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)) @@ -318,7 +319,10 @@ export class PowGpu extends WorkerInterface { uboView.setUint32(36, threshold, true) PowGpu.#device.queue.writeBuffer(PowGpu.#uboBuffer, 0, uboView) - // Work buffer + // Reset offset 8 `found` flag to 0u in WORK before each calculation + PowGpu.#device.queue.writeBuffer(PowGpu.#gpuBuffer, 8, new Uint32Array([0])) + + // Bind UBO read and GPU write buffers const bindGroup = PowGpu.#device.createBindGroup({ layout: PowGpu.#bindGroupLayout, entries: [ -- 2.34.1