/**
* Initialize (nonce||blockhash) concatenation
*/
- var nonce: vec2<u32> = ubo.random ^ vec2(id.x, id.y);
+ var m0: vec2<u32> = ubo.random ^ vec2(id.x, id.y);
var m1: vec2<u32> = vec2(ubo.blockhash[0u].x, ubo.blockhash[0u].y);
var m2: vec2<u32> = vec2(ubo.blockhash[0u].z, ubo.blockhash[0u].w);
var m3: vec2<u32> = vec2(ubo.blockhash[1u].x, ubo.blockhash[1u].y);
v0 = v0 + v4 + vec2(0u, u32(v0.x + v4.x < v0.x));
// a = a + m[sigma[r][2*i+0]]
- v0 = v0 + nonce + vec2(0u, u32(v0.x + nonce.x < v0.x));
+ v0 = v0 + m0 + vec2(0u, u32(v0.x + m0.x < v0.x));
// d = rotr64(d ^ a, 32)
v12 = v12.yx ^ v0.yx;
v1 = v1 + v6 + vec2(0u, u32(v1.x + v6.x < v1.x));
// a = a + m[sigma[r][2*i+0]]
- v1 = v1 + nonce + vec2(0u, u32(v1.x + nonce.x < v1.x));
+ v1 = v1 + m0 + vec2(0u, u32(v1.x + m0.x < v1.x));
// d = rotr64(d ^ a, 32)
v12 = v12.yx ^ v1.yx;
v1 = v1 + v5 + vec2(0u, u32(v1.x + v5.x < v1.x));
// a = a + m[sigma[r][2*i+1]]
- v1 = v1 + nonce + vec2(0u, u32(v1.x + nonce.x < v1.x));
+ v1 = v1 + m0 + vec2(0u, u32(v1.x + m0.x < v1.x));
// d = rotr64(d ^ a, 16)
v13 = ((v13 ^ v1).xy >> ROTATE_16) | ((v13 ^ v1).yx << ROTATE_16);
v2 = v2 + v7 + vec2(0u, u32(v2.x + v7.x < v2.x));
// a = a + m[sigma[r][2*i+1]]
- v2 = v2 + nonce + vec2(0u, u32(v2.x + nonce.x < v2.x));
+ v2 = v2 + m0 + vec2(0u, u32(v2.x + m0.x < v2.x));
// d = rotr64(d ^ a, 16)
v13 = ((v13 ^ v2).xy >> ROTATE_16) | ((v13 ^ v2).yx << ROTATE_16);
v0 = v0 + v4 + vec2(0u, u32(v0.x + v4.x < v0.x));
// a = a + m[sigma[r][2*i+1]]
- v0 = v0 + nonce + vec2(0u, u32(v0.x + nonce.x < v0.x));
+ v0 = v0 + m0 + vec2(0u, u32(v0.x + m0.x < v0.x));
// d = rotr64(d ^ a, 16)
v12 = ((v12 ^ v0).xy >> ROTATE_16) | ((v12 ^ v0).yx << ROTATE_16);
v2 = v2 + v6 + vec2(0u, u32(v2.x + v6.x < v2.x));
// a = a + m[sigma[r][2*i+0]]
- v2 = v2 + nonce + vec2(0u, u32(v2.x + nonce.x < v2.x));
+ v2 = v2 + m0 + vec2(0u, u32(v2.x + m0.x < v2.x));
// d = rotr64(d ^ a, 32)
v14 = v14.yx ^ v2.yx;
v0 = v0 + v5 + vec2(0u, u32(v0.x + v5.x < v0.x));
// a = a + m[sigma[r][2*i+0]]
- v0 = v0 + nonce + vec2(0u, u32(v0.x + nonce.x < v0.x));
+ v0 = v0 + m0 + vec2(0u, u32(v0.x + m0.x < v0.x));
// d = rotr64(d ^ a, 32)
v15 = v15.yx ^ v0.yx;
v0 = v0 + v5 + vec2(0u, u32(v0.x + v5.x < v0.x));
// a = a + m[sigma[r][2*i+1]]
- v0 = v0 + nonce + vec2(0u, u32(v0.x + nonce.x < v0.x));
+ v0 = v0 + m0 + vec2(0u, u32(v0.x + m0.x < v0.x));
// d = rotr64(d ^ a, 16)
v15 = ((v15 ^ v0).xy >> ROTATE_16) | ((v15 ^ v0).yx << ROTATE_16);
v3 = v3 + v7 + vec2(0u, u32(v3.x + v7.x < v3.x));
// a = a + m[sigma[r][2*i+0]]
- v3 = v3 + nonce + vec2(0u, u32(v3.x + nonce.x < v3.x));
+ v3 = v3 + m0 + vec2(0u, u32(v3.x + m0.x < v3.x));
// d = rotr64(d ^ a, 32)
v15 = v15.yx ^ v3.yx;
v3 = v3 + v4 + vec2(0u, u32(v3.x + v4.x < v3.x));
// a = a + m[sigma[r][2*i+1]]
- v3 = v3 + nonce + vec2(0u, u32(v3.x + nonce.x < v3.x));
+ v3 = v3 + m0 + vec2(0u, u32(v3.x + m0.x < v3.x));
// d = rotr64(d ^ a, 16)
v14 = ((v14 ^ v3).xy >> ROTATE_16) | ((v14 ^ v3).yx << ROTATE_16);
v0 = v0 + v4 + vec2(0u, u32(v0.x + v4.x < v0.x));
// a = a + m[sigma[r][2*i+0]]
- v0 = v0 + nonce + vec2(0u, u32(v0.x + nonce.x < v0.x));
+ v0 = v0 + m0 + vec2(0u, u32(v0.x + m0.x < v0.x));
// d = rotr64(d ^ a, 32)
v12 = v12.yx ^ v0.yx;
v1 = v1 + v6 + vec2(0u, u32(v1.x + v6.x < v1.x));
// a = a + m[sigma[r][2*i+0]]
- v1 = v1 + nonce + vec2(0u, u32(v1.x + nonce.x < v1.x));
+ v1 = v1 + m0 + vec2(0u, u32(v1.x + m0.x < v1.x));
// d = rotr64(d ^ a, 32)
v12 = v12.yx ^ v1.yx;
****************************************************************************/
/**
- * Set nonce if it passes the threshold and no other thread has set it
+ * Set m0 if it passes the threshold and no other thread has set it
*/
if ((BLAKE2B_IV32_1 ^ v0.y ^ v8.y) > threshold && atomicLoad(&work.found) == 0u) {
atomicStore(&work.found, 1u);
- work.nonce = nonce;
+ work.nonce = m0;
}
return;
}