From 9a8453d07e754e73630d21bec8c31ff0ab6298e8 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Tue, 1 Nov 2022 22:18:53 +0100 Subject: [PATCH] radv: Use compares for node type in traversal. The HW has no bit test instruction, so we change 3 pairs of and+cmp to a single and + 3 cmps, saving 2 VALU instructions. Part-of: --- src/amd/vulkan/radv_rt_common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/amd/vulkan/radv_rt_common.c b/src/amd/vulkan/radv_rt_common.c index acc1bef9f51..97a70a5ce60 100644 --- a/src/amd/vulkan/radv_rt_common.c +++ b/src/amd/vulkan/radv_rt_common.c @@ -641,11 +641,12 @@ radv_build_ray_traversal(struct radv_device *device, nir_builder *b, nir_load_deref(b, args->vars.dir), nir_load_deref(b, args->vars.inv_dir)); } - nir_push_if(b, nir_ine_imm(b, nir_iand_imm(b, bvh_node, 4), 0)); + nir_ssa_def *node_type = nir_iand_imm(b, bvh_node, 7); + nir_push_if(b, nir_uge(b, node_type, nir_imm_int(b, radv_bvh_node_box16))); { - nir_push_if(b, nir_ine_imm(b, nir_iand_imm(b, bvh_node, 2), 0)); + nir_push_if(b, nir_uge(b, node_type, nir_imm_int(b, radv_bvh_node_instance))); { - nir_push_if(b, nir_ine_imm(b, nir_iand_imm(b, bvh_node, 1), 0)); + nir_push_if(b, nir_ieq_imm(b, node_type, radv_bvh_node_aabb)); { insert_traversal_aabb_case(device, b, args, global_bvh_node); }