From 4fe2ddf5e24fcee19ad072735ac6cfc250a3ed07 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 12 Jun 2026 11:40:49 +0100 Subject: [PATCH] radv/bvh: use atomic load/store in update_gfx12.comp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It looks like these are used to synchronize access to args.bounds, but they were not atomic. Signed-off-by: Rhys Perry Fixes: 2d48b2cb473 ("radv: Use subgroup OPs for BVH updates on GFX12") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15641 Reviewed-by: Georg Lehmann Reviewed-by: Konstantin Seurer Reviewed-by: Timur Kristóf Part-of: --- src/amd/vulkan/bvh/update_gfx12.comp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/amd/vulkan/bvh/update_gfx12.comp b/src/amd/vulkan/bvh/update_gfx12.comp index cfbaee947b9..6205fb7d652 100644 --- a/src/amd/vulkan/bvh/update_gfx12.comp +++ b/src/amd/vulkan/bvh/update_gfx12.comp @@ -97,8 +97,10 @@ main() bool is_ready = is_leaf_or_invalid; while (true) { - if (!is_ready) - is_ready = DEREF(INDEX(uint32_t, args.internal_ready_count, child_index)) != 0; + if (!is_ready) { + is_ready = atomicLoad(DEREF(INDEX(uint32_t, args.internal_ready_count, child_index)), + gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire | gl_SemanticsMakeVisible) != 0; + } if (radv_ballot(cluster, is_ready) != 0xff) continue; @@ -121,13 +123,8 @@ main() } else { DEREF(INDEX(vk_aabb, args.bounds, node_index - 1)) = total_bounds; - memoryBarrier(gl_ScopeDevice, gl_StorageSemanticsBuffer, - gl_SemanticsAcquireRelease | gl_SemanticsMakeAvailable | gl_SemanticsMakeVisible); - - DEREF(INDEX(uint32_t, args.internal_ready_count, node_index - 1)) = 1; - - memoryBarrier(gl_ScopeDevice, gl_StorageSemanticsBuffer, - gl_SemanticsAcquireRelease | gl_SemanticsMakeAvailable | gl_SemanticsMakeVisible); + atomicStore(DEREF(INDEX(uint32_t, args.internal_ready_count, node_index - 1)), 1u, gl_ScopeDevice, + gl_StorageSemanticsBuffer, gl_SemanticsRelease | gl_SemanticsMakeAvailable); } }