diff options
author | Konstantin Seurer <konstantin.seurer@gmail.com> | 2023-01-11 22:53:53 +0100 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-01-21 20:26:41 +0000 |
commit | d59683ab8986f977cc91d09fc251f6ed971f0e41 (patch) | |
tree | 9855f560f5560af90e4ef7b83751537e5a5f3c24 | |
parent | da87c2883df68fd8948037521668526dd150f0c2 (diff) | |
download | mesa-d59683ab8986f977cc91d09fc251f6ed971f0e41.tar.gz mesa-d59683ab8986f977cc91d09fc251f6ed971f0e41.tar.bz2 mesa-d59683ab8986f977cc91d09fc251f6ed971f0e41.zip |
radv: Enable extended SAH for shallow BVHs
Reviewed-by: Friedrich Vock <friedrich.vock@gmx.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20656>
-rw-r--r-- | src/amd/vulkan/radv_acceleration_structure.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/amd/vulkan/radv_acceleration_structure.c b/src/amd/vulkan/radv_acceleration_structure.c index af85df38dcb..6e6bf7107c3 100644 --- a/src/amd/vulkan/radv_acceleration_structure.c +++ b/src/amd/vulkan/radv_acceleration_structure.c @@ -78,6 +78,7 @@ enum internal_build_type { struct build_config { enum internal_build_type internal_type; + bool extended_sah; }; struct acceleration_structure_layout { @@ -116,6 +117,11 @@ build_config(uint32_t leaf_count, const VkAccelerationStructureBuildGeometryInfo else config.internal_type = INTERNAL_BUILD_TYPE_LBVH; + /* 4^(lds stack entry count) assuming we push 1 node on average. */ + uint32_t lds_spill_threshold = 1 << (8 * 2); + if (leaf_count < lds_spill_threshold) + config.extended_sah = true; + return config; } @@ -888,15 +894,19 @@ lbvh_build_internal(VkCommandBuffer commandBuffer, uint32_t infoCount, static void ploc_build_internal(VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, - struct bvh_state *bvh_states) + struct bvh_state *bvh_states, bool extended_sah) { RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); - radv_CmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, - cmd_buffer->device->meta_state.accel_struct_build.ploc_pipeline); + radv_CmdBindPipeline( + commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, + extended_sah ? cmd_buffer->device->meta_state.accel_struct_build.ploc_extended_pipeline + : cmd_buffer->device->meta_state.accel_struct_build.ploc_pipeline); for (uint32_t i = 0; i < infoCount; ++i) { if (bvh_states[i].config.internal_type != INTERNAL_BUILD_TYPE_PLOC) continue; + if (bvh_states[i].config.extended_sah != extended_sah) + continue; struct radv_global_sync_data initial_sync_data = { .current_phase_end_counter = TASK_INDEX_INVALID, @@ -1065,7 +1075,9 @@ radv_CmdBuildAccelerationStructuresKHR( cmd_buffer->state.flush_bits |= flush_bits; lbvh_build_internal(commandBuffer, infoCount, pInfos, bvh_states, flush_bits); - ploc_build_internal(commandBuffer, infoCount, pInfos, bvh_states); + + ploc_build_internal(commandBuffer, infoCount, pInfos, bvh_states, false); + ploc_build_internal(commandBuffer, infoCount, pInfos, bvh_states, true); cmd_buffer->state.flush_bits |= flush_bits; |