From 608fa1bd25fddd4f47c8a0037f849575089ac5d8 Mon Sep 17 00:00:00 2001 From: Friedrich Vock Date: Fri, 28 Oct 2022 00:01:51 +0200 Subject: [PATCH] radv/rt: Track number of inactive leaf nodes To avoid emitting nodes with only invalid children in PLOC. Reviewed-by: Konstantin Seurer Part-of: --- src/amd/vulkan/bvh/bvh.h | 1 + src/amd/vulkan/bvh/converter_internal.comp | 1 + src/amd/vulkan/bvh/leaf.comp | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/src/amd/vulkan/bvh/bvh.h b/src/amd/vulkan/bvh/bvh.h index cddefb562de..901a4b32524 100644 --- a/src/amd/vulkan/bvh/bvh.h +++ b/src/amd/vulkan/bvh/bvh.h @@ -135,6 +135,7 @@ struct radv_ir_instance_node { struct radv_ir_header { int32_t min_bounds[3]; int32_t max_bounds[3]; + uint32_t active_leaf_count; /* Indirect dispatch dimensions for the internal node converter. * ir_internal_node_count is the thread count in the X dimension, * while Y and Z are always set to 1. */ diff --git a/src/amd/vulkan/bvh/converter_internal.comp b/src/amd/vulkan/bvh/converter_internal.comp index d9ce47a3d52..0f85f468665 100644 --- a/src/amd/vulkan/bvh/converter_internal.comp +++ b/src/amd/vulkan/bvh/converter_internal.comp @@ -146,6 +146,7 @@ main() if (valid_grandchild_count > 0) children[collapsed_child_index] = grandchildren[0]; + if (in_final_tree == FINAL_TREE_PRESENT) DEREF(child_node).in_final_tree = FINAL_TREE_NOT_PRESENT; } else diff --git a/src/amd/vulkan/bvh/leaf.comp b/src/amd/vulkan/bvh/leaf.comp index 71f48bec7d9..a338969dc5a 100644 --- a/src/amd/vulkan/bvh/leaf.comp +++ b/src/amd/vulkan/bvh/leaf.comp @@ -33,6 +33,9 @@ #extension GL_EXT_scalar_block_layout : require #extension GL_EXT_buffer_reference : require #extension GL_EXT_buffer_reference2 : require +#extension GL_KHR_shader_subgroup_vote : require +#extension GL_KHR_shader_subgroup_arithmetic : require +#extension GL_KHR_shader_subgroup_ballot : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; @@ -300,6 +303,10 @@ main(void) DEREF(id_ptr).id = is_active ? pack_ir_node_id(dst_offset, node_type) : RADV_BVH_INVALID_NODE; + uvec4 ballot = subgroupBallot(is_active); + if (subgroupElect()) + atomicAdd(DEREF(args.header).active_leaf_count, subgroupBallotBitCount(ballot)); + atomicMin(DEREF(args.header).min_bounds[0], to_emulated_float(bounds.min.x)); atomicMin(DEREF(args.header).min_bounds[1], to_emulated_float(bounds.min.y)); atomicMin(DEREF(args.header).min_bounds[2], to_emulated_float(bounds.min.z));