]> zoso.dev Git - nano-pow.git/commitdiff
Flip compute shader UBO property order to be consistent with GL draw shader and to...
authorChris Duncan <chris@zoso.dev>
Thu, 13 Mar 2025 15:28:30 +0000 (08:28 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 13 Mar 2025 15:28:30 +0000 (08:28 -0700)
src/classes/gpu.ts
src/shaders/compute.wgsl

index 9c33c150bd77ce681c73bcfef37c58a26de4f3b2..44e52c1845e4c0d5928f14d8e58cbd46851a5908 100644 (file)
@@ -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'))
index 32d14b9d4120dafff333951ccb00e7eef88c9aab..d96aca48b7cfca68be1884712795ba94d30600e7 100644 (file)
@@ -15,8 +15,8 @@ struct UBO {
 * Output buffers
 */
 struct WORK {
-       nonce: vec2<u32>,
        found: atomic<u32>,
+       nonce: vec2<u32>,
        result: vec2<u32>
 };
 @group(0) @binding(1) var<storage, read_write> work: WORK;