From 97aa3464b907fc0f2b5267892799424f86950aa5 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 24 Jul 2024 12:45:30 +0200 Subject: [PATCH] radv/rt: remove one VALU from traversal loop Not much, but something, I guess? Foz-DB Navi31: Totals from 93 (0.12% of 79395) affected shaders: MaxWaves: 1338 -> 1354 (+1.20%) Instrs: 3689907 -> 3689721 (-0.01%); split: -0.01%, +0.00% CodeSize: 18921812 -> 18922920 (+0.01%); split: -0.00%, +0.01% VGPRs: 9012 -> 8988 (-0.27%) Latency: 23153748 -> 23167640 (+0.06%) InvThroughput: 4490882 -> 4493136 (+0.05%) Copies: 287888 -> 287728 (-0.06%) VALU: 2022082 -> 2021916 (-0.01%) SALU: 458904 -> 459064 (+0.03%) Reviewed-by: Konstantin Seurer Part-of: --- src/amd/vulkan/nir/radv_nir_rt_common.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/amd/vulkan/nir/radv_nir_rt_common.c b/src/amd/vulkan/nir/radv_nir_rt_common.c index 60683550d98..2b80d2574c3 100644 --- a/src/amd/vulkan/nir/radv_nir_rt_common.c +++ b/src/amd/vulkan/nir/radv_nir_rt_common.c @@ -560,12 +560,11 @@ radv_build_ray_traversal(struct radv_device *device, nir_builder *b, const struc nir_load_deref(b, args->vars.dir), nir_load_deref(b, args->vars.inv_dir)); } - nir_def *node_type = nir_iand_imm(b, bvh_node, 7); - nir_push_if(b, nir_uge_imm(b, node_type, radv_bvh_node_box16)); + nir_push_if(b, nir_test_mask(b, bvh_node, BITFIELD64_BIT(ffs(radv_bvh_node_box16) - 1))); { - nir_push_if(b, nir_uge_imm(b, node_type, radv_bvh_node_instance)); + nir_push_if(b, nir_test_mask(b, bvh_node, BITFIELD64_BIT(ffs(radv_bvh_node_instance) - 1))); { - nir_push_if(b, nir_ieq_imm(b, node_type, radv_bvh_node_aabb)); + nir_push_if(b, nir_test_mask(b, bvh_node, BITFIELD64_BIT(ffs(radv_bvh_node_aabb) - 1))); { insert_traversal_aabb_case(device, b, args, &ray_flags, global_bvh_node); }