From a3df3ebab470c5f5010bc3ec1e0c44b6e24d1423 Mon Sep 17 00:00:00 2001 From: Friedrich Vock Date: Fri, 2 Aug 2024 08:20:13 +0200 Subject: [PATCH] radv/rt: Only do ploc atomicCompSwap once per workgroup There is no need to do this for every invocation in the wave. Improves GravityMark scores by 5%. Part-of: --- src/amd/vulkan/bvh/ploc_internal.comp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/amd/vulkan/bvh/ploc_internal.comp b/src/amd/vulkan/bvh/ploc_internal.comp index d1aec917b03..53abccb8e4f 100644 --- a/src/amd/vulkan/bvh/ploc_internal.comp +++ b/src/amd/vulkan/bvh/ploc_internal.comp @@ -216,10 +216,16 @@ main(void) return; } - atomicCompSwap(DEREF(args.header).sync_data.task_counts[0], 0xFFFFFFFF, - DEREF(args.header).active_leaf_count); - atomicCompSwap(DEREF(args.header).sync_data.current_phase_end_counter, 0xFFFFFFFF, - DIV_ROUND_UP(DEREF(args.header).active_leaf_count, gl_WorkGroupSize.x)); + /* Only initialize sync_data once per workgroup. For intra-workgroup synchronization, + * fetch_task contains a workgroup-scoped control+memory barrier. + */ + if (gl_LocalInvocationIndex == 0) { + atomicCompSwap(DEREF(args.header).sync_data.task_counts[0], 0xFFFFFFFF, + DEREF(args.header).active_leaf_count); + atomicCompSwap(DEREF(args.header).sync_data.current_phase_end_counter, 0xFFFFFFFF, + DIV_ROUND_UP(DEREF(args.header).active_leaf_count, gl_WorkGroupSize.x)); + } + REF(ploc_prefix_scan_partition) partitions = REF(ploc_prefix_scan_partition)(args.prefix_scan_partitions);