54 lines
2.6 KiB
Diff
54 lines
2.6 KiB
Diff
From 64c406774fc56e6b63b2352f3ab63fcb9cb10d21 Mon Sep 17 00:00:00 2001
|
|
From: Friedrich Vock <friedrich.vock@gmx.de>
|
|
Date: Mon, 30 Sep 2024 15:09:39 +0200
|
|
Subject: [PATCH] radv/rt: Skip all AABB code when no_skip_aabbs is not set
|
|
|
|
This avoids having to execute the load_global just to throw the results
|
|
away and ignore the node.
|
|
|
|
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31443>
|
|
---
|
|
src/amd/vulkan/nir/radv_nir_rt_common.c | 28 +++++++++++++------------
|
|
1 file changed, 15 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/src/amd/vulkan/nir/radv_nir_rt_common.c b/src/amd/vulkan/nir/radv_nir_rt_common.c
|
|
index 37b934d0f7ad9..6e35914f462bc 100644
|
|
--- a/src/amd/vulkan/nir/radv_nir_rt_common.c
|
|
+++ b/src/amd/vulkan/nir/radv_nir_rt_common.c
|
|
@@ -418,20 +418,22 @@ insert_traversal_aabb_case(struct radv_device *device, nir_builder *b, const str
|
|
if (!args->aabb_cb)
|
|
return;
|
|
|
|
- struct radv_leaf_intersection intersection;
|
|
- intersection.node_addr = build_node_to_addr(device, b, bvh_node, false);
|
|
- nir_def *triangle_info = nir_build_load_global(
|
|
- b, 2, 32, nir_iadd_imm(b, intersection.node_addr, offsetof(struct radv_bvh_aabb_node, primitive_id)));
|
|
- intersection.primitive_id = nir_channel(b, triangle_info, 0);
|
|
- intersection.geometry_id_and_flags = nir_channel(b, triangle_info, 1);
|
|
- intersection.opaque = hit_is_opaque(b, nir_load_deref(b, args->vars.sbt_offset_and_flags), ray_flags,
|
|
- intersection.geometry_id_and_flags);
|
|
-
|
|
- nir_def *not_cull = nir_bcsel(b, intersection.opaque, ray_flags->no_cull_opaque, ray_flags->no_cull_no_opaque);
|
|
- not_cull = nir_iand(b, not_cull, ray_flags->no_skip_aabbs);
|
|
- nir_push_if(b, not_cull);
|
|
+ nir_push_if(b, ray_flags->no_skip_aabbs);
|
|
{
|
|
- args->aabb_cb(b, &intersection, args);
|
|
+ struct radv_leaf_intersection intersection;
|
|
+ intersection.node_addr = build_node_to_addr(device, b, bvh_node, false);
|
|
+ nir_def *triangle_info = nir_build_load_global(
|
|
+ b, 2, 32, nir_iadd_imm(b, intersection.node_addr, offsetof(struct radv_bvh_aabb_node, primitive_id)));
|
|
+ intersection.primitive_id = nir_channel(b, triangle_info, 0);
|
|
+ intersection.geometry_id_and_flags = nir_channel(b, triangle_info, 1);
|
|
+ intersection.opaque = hit_is_opaque(b, nir_load_deref(b, args->vars.sbt_offset_and_flags), ray_flags,
|
|
+ intersection.geometry_id_and_flags);
|
|
+
|
|
+ nir_push_if(b, nir_bcsel(b, intersection.opaque, ray_flags->no_cull_opaque, ray_flags->no_cull_no_opaque));
|
|
+ {
|
|
+ args->aabb_cb(b, &intersection, args);
|
|
+ }
|
|
+ nir_pop_if(b, NULL);
|
|
}
|
|
nir_pop_if(b, NULL);
|
|
}
|
|
--
|