From 854120aba03b0863426e4883a0903a6a9fd8669f Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Mon, 1 Apr 2024 16:55:32 -0700 Subject: [PATCH] [binning] Do not use numerical operators on atomics (#539) This fixes a comparison expression and a compound-assignment expression that used an atomic as an operand. These should be treated as illegal based on my understanding of the WGSL specification (and are rejected by Tint) but Naga accepts them and injects appropriate atomic operations during code generation. See https://github.com/gfx-rs/wgpu/issues/5474 for more details. --- shader/binning.wgsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shader/binning.wgsl b/shader/binning.wgsl index 55d80c350..91048272e 100644 --- a/shader/binning.wgsl +++ b/shader/binning.wgsl @@ -65,14 +65,14 @@ fn main( atomicStore(&sh_bitmaps[i][local_id.x], 0u); } if local_id.x == 0u { - let failed = bump.lines > config.lines_size; + let failed = atomicLoad(&bump.lines) > config.lines_size; sh_previous_failed = u32(failed); } // also functions as barrier to protect zeroing of bitmaps let failed = workgroupUniformLoad(&sh_previous_failed); if failed != 0u { if global_id.x == 0u { - bump.failed |= STAGE_FLATTEN; + atomicOr(&bump.failed, STAGE_FLATTEN); } return; }