From b46ffcc9c724d5efc025aac34a088c678cc4d825 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 16 Jan 2025 07:30:04 -0800 Subject: [PATCH] Prune steps from final round that do not affect final outcome. --- src/shaders/compute.wgsl | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/shaders/compute.wgsl b/src/shaders/compute.wgsl index 2da6c74..2895232 100644 --- a/src/shaders/compute.wgsl +++ b/src/shaders/compute.wgsl @@ -1467,7 +1467,7 @@ fn main(id: vec3) { // skip since adding 0u does nothing v12 = ((v12 ^ v0).xy >> ROTATE_16) | ((v12 ^ v0).yx << ROTATE_16); v8 = v8 + v12 + vec2(0u, u32(v8.x + v12.x < v8.x)); - v4 = ((v4 ^ v8).xy << ROTATE_1) | ((v4 ^ v8).yx >> ROTATE_31); + // skip since it does not affect the final values of `v0` and `v8` /** * r=11, i=1, a=v[1], b=v[5], c=v[9], d=v[13] @@ -1495,7 +1495,7 @@ fn main(id: vec3) { // skip since adding 0u does nothing v14 = ((v14 ^ v2).xy >> ROTATE_16) | ((v14 ^ v2).yx << ROTATE_16); v10 = v10 + v14 + vec2(0u, u32(v10.x + v14.x < v10.x)); - v6 = ((v6 ^ v10).xy << ROTATE_1) | ((v6 ^ v10).yx >> ROTATE_31); + // skip since it does not affect the final values of `v0` and `v8` /** * r=11, i=3, a=v[3], b=v[7], c=v[11], d=v[15] @@ -1521,23 +1521,14 @@ fn main(id: vec3) { v5 = ((v5 ^ v10).xy >> ROTATE_24) | ((v5 ^ v10).yx << ROTATE_8); v0 = v0 + v5 + vec2(0u, u32(v0.x + v5.x < v0.x)); // skip since adding 0u does nothing - v15 = ((v15 ^ v0).xy >> ROTATE_16) | ((v15 ^ v0).yx << ROTATE_16); - v10 = v10 + v15 + vec2(0u, u32(v10.x + v15.x < v10.x)); - v5 = ((v5 ^ v10).xy << ROTATE_1) | ((v5 ^ v10).yx >> ROTATE_31); + // skip since it does not affect the final values of `v0` and `v8` + // skip since it does not affect the final values of `v0` and `v8` + // skip since it does not affect the final values of `v0` and `v8` /** * r=11, i=5, a=v[1], b=v[6], c=v[11], d=v[12] */ - v1 = v1 + v6 + vec2(0u, u32(v1.x + v6.x < v1.x)); - v1 = v1 + m0 + vec2(0u, u32(v1.x + m0.x < v1.x)); - v12 = v12.yx ^ v1.yx; - v11 = v11 + v12 + vec2(0u, u32(v11.x + v12.x < v11.x)); - v6 = ((v6 ^ v11).xy >> ROTATE_24) | ((v6 ^ v11).yx << ROTATE_8); - v1 = v1 + v6 + vec2(0u, u32(v1.x + v6.x < v1.x)); - v1 = v1 + m2 + vec2(0u, u32(v1.x + m2.x < v1.x)); - v12 = ((v12 ^ v1).xy >> ROTATE_16) | ((v12 ^ v1).yx << ROTATE_16); - v11 = v11 + v12 + vec2(0u, u32(v11.x + v12.x < v11.x)); - v6 = ((v6 ^ v11).xy << ROTATE_1) | ((v6 ^ v11).yx >> ROTATE_31); + // skip entire step since it does not affect the final values of `v0` and `v8` /** * r=11, i=6, a=v[2], b=v[7], c=v[8], d=v[13] -- 2.34.1