From 6fd7b3920f06afd1253501d8b9d01d65415273fe Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 13 Mar 2025 08:28:30 -0700 Subject: [PATCH] Flip compute shader UBO property order to be consistent with GL draw shader and to allow properties to be added later without messing up alignment too much. --- src/classes/gpu.ts | 9 +++++---- src/shaders/compute.wgsl | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/classes/gpu.ts b/src/classes/gpu.ts index 9c33c15..44e52c1 100644 --- a/src/classes/gpu.ts +++ b/src/classes/gpu.ts @@ -260,9 +260,10 @@ export class NanoPowGpu { const seed = (BigInt(random0) << 32n) | BigInt(random1) if (this.#debug) console.log('seed', seed.toString(16).padStart(16, '0')) const data = await this.#dispatch(this.#searchPipeline, seed, hash, threshold, effort) - nonce = data.getBigUint64(0, true) - this.#busy = !data.getUint32(8) + const found = !!data.getUint32(0) + nonce = data.getBigUint64(8, true) if (this.#debug) console.log('result', data.getBigUint64(16).toString(16).padStart(16, '0')) + this.#busy = !found times.push(performance.now() - start) } while (this.#busy) if (this.#debug) this.#logAverages(times) @@ -313,8 +314,8 @@ export class NanoPowGpu { const seed = BigInt(`0x${work}`) if (this.#debug) console.log('work', work) const data = await this.#dispatch(this.#validatePipeline, seed, hash, threshold, 1) - const nonce = data.getBigUint64(0, true) - const found = !!data.getUint32(8) + const found = !!data.getUint32(0) + const nonce = data.getBigUint64(8, true) if (this.#debug) console.log('result', data.getBigUint64(16).toString(16).padStart(16, '0')) this.#busy = false if (this.#debug) console.log('nonce', nonce, nonce.toString(16).padStart(16, '0')) diff --git a/src/shaders/compute.wgsl b/src/shaders/compute.wgsl index 32d14b9..d96aca4 100644 --- a/src/shaders/compute.wgsl +++ b/src/shaders/compute.wgsl @@ -15,8 +15,8 @@ struct UBO { * Output buffers */ struct WORK { - nonce: vec2, found: atomic, + nonce: vec2, result: vec2 }; @group(0) @binding(1) var work: WORK; -- 2.34.1