radv: Use compares for node type in traversal.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tue, 1 Nov 2022 21:18:53 +0000 (22:18 +0100)
committerMarge Bot <emma+marge@anholt.net>
Sat, 5 Nov 2022 16:38:48 +0000 (16:38 +0000)
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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19454>

src/amd/vulkan/radv_rt_common.c

index acc1bef9f51e1840c9bdcade4aba7738689a2faa..97a70a5ce60296772d0ad883ea917135d6fcfc13 100644 (file)
@@ -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);
                }