@group(0) @binding(0) var<uniform> ubo: UBO;
struct WORK {
- found: atomic<u32>,
- nonce: vec2<u32>
+ nonce: vec2<u32>,
+ found: atomic<u32>
};
@group(0) @binding(1) var<storage, read_write> work: WORK;
work.nonce.y = m[1];
return;
}
-
- /**
- * Nonce not found in this execution context
- */
return;
}
`;
PowGpu.#device.queue.writeBuffer(PowGpu.#uboBuffer, 0, uboView)
// Reset `found` flag to 0u in WORK before each calculation
- PowGpu.#device.queue.writeBuffer(PowGpu.#gpuBuffer, 0, new Uint32Array([0]))
+ PowGpu.#device.queue.writeBuffer(PowGpu.#gpuBuffer, 8, new Uint32Array([0]))
// Bind UBO read and GPU write buffers
const bindGroup = PowGpu.#device.createBindGroup({
await PowGpu.#cpuBuffer.mapAsync(GPUMapMode.READ)
await PowGpu.#device.queue.onSubmittedWorkDone()
const data = new DataView(PowGpu.#cpuBuffer.getMappedRange())
- const found = !!data.getUint32(0)
- const nonce = data.getBigUint64(8, true)
+ const nonce = data.getBigUint64(0, true)
+ const found = !!data.getUint32(8)
PowGpu.#cpuBuffer.unmap()
if (found) {