From f502b3aab335a1669bbf894923ee4cf245ab4f04 Mon Sep 17 00:00:00 2001 From: Friedrich Vock Date: Fri, 28 Oct 2022 22:02:07 +0200 Subject: [PATCH] radv/rt: Dispatch internal converter indirectly Preparation for using the converter with PLOC. Reviewed-by: Konstantin Seurer Part-of: --- src/amd/vulkan/bvh/bvh.h | 5 +++++ src/amd/vulkan/radv_acceleration_structure.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/bvh/bvh.h b/src/amd/vulkan/bvh/bvh.h index 7c8e1f20445..cddefb562de 100644 --- a/src/amd/vulkan/bvh/bvh.h +++ b/src/amd/vulkan/bvh/bvh.h @@ -135,7 +135,12 @@ struct radv_ir_instance_node { struct radv_ir_header { int32_t min_bounds[3]; int32_t max_bounds[3]; + /* 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. */ uint32_t ir_internal_node_count; + uint32_t dispatch_size_y; + uint32_t dispatch_size_z; }; struct radv_bvh_triangle_node { diff --git a/src/amd/vulkan/radv_acceleration_structure.c b/src/amd/vulkan/radv_acceleration_structure.c index dca9a85fc9c..06a97224c3e 100644 --- a/src/amd/vulkan/radv_acceleration_structure.c +++ b/src/amd/vulkan/radv_acceleration_structure.c @@ -725,7 +725,10 @@ convert_internal_nodes(VkCommandBuffer commandBuffer, uint32_t infoCount, radv_CmdPushConstants( commandBuffer, cmd_buffer->device->meta_state.accel_struct_build.convert_internal_p_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(args), &args); - radv_unaligned_dispatch(cmd_buffer, bvh_states[i].internal_node_count, 1, 1); + radv_indirect_unaligned_dispatch(cmd_buffer, NULL, + pInfos[i].scratchData.deviceAddress + + bvh_states[i].scratch.header_offset + + offsetof(struct radv_ir_header, ir_internal_node_count)); } /* This is the final access to the leaf nodes, no need to flush */ } @@ -760,9 +763,13 @@ radv_CmdBuildAccelerationStructuresKHR( get_build_layout(cmd_buffer->device, leaf_node_count, pInfos + i, &bvh_states[i].accel_struct, &bvh_states[i].scratch); + /* The internal node count is updated in lbvh_build_internal for LBVH + * and from the PLOC shader for PLOC. */ struct radv_ir_header header = { .min_bounds = {0x7fffffff, 0x7fffffff, 0x7fffffff}, .max_bounds = {0x80000000, 0x80000000, 0x80000000}, + .dispatch_size_y = 1, + .dispatch_size_z = 1, }; radv_update_buffer_cp(