return;
}
var id: u32 = ((workgroup_id.x & 0xff) << 24) |
- ((workgroup_id.y & 0xff) << 16) |
- ((workgroup_id.z & 0xff) << 8) |
- (local_id.x & 0xff);
+ ((workgroup_id.y & 0xff) << 16) |
+ ((workgroup_id.z & 0xff) << 8) |
+ (local_id.x & 0xff);
var m: array<u32, 16>;
m[0u] = ubo.random;
m[1u] = id ^ ubo.random;
m[9u] = ubo.blockhash[1u].w;
/**
- * Compression buffer, intialized to 2 instances of the initialization vector
+ * Compression buffer intialized to 2 instances of initialization vector
* The following values have been modified from the BLAKE2B_IV:
* OUTLEN is constant 8 bytes
* v[0u] ^= 0x01010000u ^ uint(OUTLEN);
* INLEN is constant 40 bytes: work value (8) + block hash (32)
* v[24u] ^= uint(INLEN);
- * It's always the "last" compression at this INLEN
+ * It is always the "last" compression at this INLEN
* v[28u] = ~v[28u];
* v[29u] = ~v[29u];
*/
return;
}
+ /**
+ * Nonce not found in this execution context
+ */
return;
}
`;
}
// Set up uniform buffer object
- const uboView = new DataView(new ArrayBuffer(64))
+ // Note: u32 size is 4, but total alignment must be multiple of 16
+ const uboView = new DataView(new ArrayBuffer(48))
for (let i = 0; i < 64; i += 8) {
const uint32 = hashHex.slice(i, i + 8)
uboView.setUint32(i / 2, parseInt(uint32, 16))
}
const random = crypto.getRandomValues(new Uint32Array(1))[0]
- console.log(`random: ${random}`)
uboView.setUint32(32, random, true)
- uboView.setUint32(48, threshold, true)
+ uboView.setUint32(36, threshold, true)
const uboBuffer = PowGpu.#device.createBuffer({
size: uboView.byteLength,
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
const data = new DataView(PowGpu.#cpuBuffer.getMappedRange())
const nonce = data.getBigUint64(0, true)
const found = !!data.getUint32(8)
- console.log(new Uint32Array(data.buffer))
PowGpu.#cpuBuffer.unmap()
if (found) {