From a0fb223ffbe4947ed150573f786248130fed758c Mon Sep 17 00:00:00 2001 From: ferreo Date: Wed, 6 Nov 2024 16:26:47 +0100 Subject: [PATCH] Add patches/radvaabb.diff --- patches/radvaabb.diff | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 patches/radvaabb.diff diff --git a/patches/radvaabb.diff b/patches/radvaabb.diff new file mode 100644 index 0000000..44aac90 --- /dev/null +++ b/patches/radvaabb.diff @@ -0,0 +1,54 @@ +From 64c406774fc56e6b63b2352f3ab63fcb9cb10d21 Mon Sep 17 00:00:00 2001 +From: Friedrich Vock +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: +--- + 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); + } +-- \ No newline at end of file