From: Chris Duncan Date: Sun, 12 Jan 2025 06:11:10 +0000 (-0800) Subject: Extend random input to shader to accomodate validation of nonces. X-Git-Tag: v1.1.0~10 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=db0c58de1600a9d9016686fd10dae09eb9f5d5a0;p=nano-pow.git Extend random input to shader to accomodate validation of nonces. --- diff --git a/src/classes/gpu.ts b/src/classes/gpu.ts index 85d907b..7b825f3 100644 --- a/src/classes/gpu.ts +++ b/src/classes/gpu.ts @@ -141,7 +141,8 @@ export class NanoPowGpu { } const random = Math.floor((Math.random() * 0xffffffff)) uboView.setUint32(32, random, true) - uboView.setUint32(36, threshold, true) + uboView.setUint32(36, random, true) + uboView.setUint32(40, threshold, true) this.#device.queue.writeBuffer(this.#uboBuffer, 0, uboView) // Reset `nonce` and `found` to 0u in WORK before each calculation diff --git a/src/shaders/compute.wgsl b/src/shaders/compute.wgsl index 8036a7d..354b65f 100644 --- a/src/shaders/compute.wgsl +++ b/src/shaders/compute.wgsl @@ -3,7 +3,7 @@ struct UBO { blockhash: array, 2>, - random: u32, + random: vec2, threshold: u32 }; @group(0) @binding(0) var ubo: UBO; @@ -35,8 +35,8 @@ fn main(@builtin(global_invocation_id) id: vec3) { /** * Initialize (nonce||blockhash) concatenation */ - var m0: u32 = ubo.random ^ id.x; - var m1: u32 = ubo.random ^ id.y; + var m0: u32 = ubo.random.x ^ id.x; + var m1: u32 = ubo.random.y ^ id.y; var m2: u32 = ubo.blockhash[0u].x; var m3: u32 = ubo.blockhash[0u].y; var m4: u32 = ubo.blockhash[0u].z;