From: Chris Duncan Date: Fri, 17 Jan 2025 18:47:09 +0000 (-0800) Subject: Avoid main function call entirely if work was already found. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=985a095ea38eb47071b23f347c06813f0c4d420c;p=nano-pow.git Avoid main function call entirely if work was already found. --- diff --git a/src/shaders/compute.wgsl b/src/shaders/compute.wgsl index 79486d0..beec4a9 100644 --- a/src/shaders/compute.wgsl +++ b/src/shaders/compute.wgsl @@ -35,6 +35,7 @@ const ROTATE_31 = vec2(31u, 31u); */ @compute @workgroup_size(8,8) fn search(@builtin(global_invocation_id) global_id: vec3) { + if (atomicLoad(&work.found) != 0u) { return; } main(global_id); } @@ -44,6 +45,7 @@ fn search(@builtin(global_invocation_id) global_id: vec3) { */ @compute @workgroup_size(1) fn validate(@builtin(global_invocation_id) global_id: vec3) { + if (atomicLoad(&work.found) != 0u) { return; } main(global_id); } @@ -58,8 +60,6 @@ fn validate(@builtin(global_invocation_id) global_id: vec3) { * performance, but the variable name still contains the original index digit. */ fn main(id: vec3) { - if (atomicLoad(&work.found) != 0u) { return; } - let threshold: u32 = ubo.threshold; /**