// Issue commands and end compute pass structure
passEncoder.setPipeline(this.#pipeline)
passEncoder.setBindGroup(0, bindGroup)
- passEncoder.dispatchWorkgroups(256, 256, 256)
+ passEncoder.dispatchWorkgroups(0xff, 0xff)
passEncoder.end()
// Copy 8-byte nonce and 4-byte found flag from GPU to CPU for reading
* 8-byte work is split into two 4-byte u32. Low 4 bytes are random u32 from
* UBO. High 4 bytes are the random value XOR'd with index of each thread.
*/
-@compute @workgroup_size(64)
-fn main(
- @builtin(workgroup_id) workgroup_id: vec3<u32>,
- @builtin(local_invocation_id) local_id: vec3<u32>
+@compute @workgroup_size(256)
+fn main(@builtin(global_invocation_id) id: vec3<u32>
) {
if (atomicLoad(&work.found) != 0u) { return; }
let threshold: u32 = ubo.threshold;
- /**
- * Flatten 3D workgroup and local identifiers into u32 for each thread
- */
- var id: u32 = ((workgroup_id.x & 0xFFu) << 24u) |
- ((workgroup_id.y & 0xFFu) << 16u) |
- ((workgroup_id.z & 0xFFu) << 8u) |
- (local_id.x & 0xFFu);
-
/**
* Initialize (nonce||blockhash) concatenation
*/
- var m0: u32 = ubo.random;
- var m1: u32 = ubo.random ^ id;
+ var m0: u32 = ubo.random ^ id.x;
+ var m1: u32 = ubo.random ^ id.y;
var m2: u32 = ubo.blockhash[0u].x;
var m3: u32 = ubo.blockhash[0u].y;
var m4: u32 = ubo.blockhash[0u].z;