diff --git a/.pick_status.json b/.pick_status.json index a794b0aa097..638487a2754 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -124,7 +124,7 @@ "description": "radv/rt: Add workaround to make leaves always active", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/vulkan/bvh/build_helpers.h b/src/amd/vulkan/bvh/build_helpers.h index 30d312716f1..1ca1ecfd837 100644 --- a/src/amd/vulkan/bvh/build_helpers.h +++ b/src/amd/vulkan/bvh/build_helpers.h @@ -156,6 +156,7 @@ #define VK_GEOMETRY_TYPE_TRIANGLES_KHR 0 #define VK_GEOMETRY_TYPE_AABBS_KHR 1 +#define VK_GEOMETRY_TYPE_INSTANCES_KHR 2 #define VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR 1 #define VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR 2 diff --git a/src/amd/vulkan/bvh/leaf.comp b/src/amd/vulkan/bvh/leaf.comp index f79ccfaf2ce..1c2dcd0563c 100644 --- a/src/amd/vulkan/bvh/leaf.comp +++ b/src/amd/vulkan/bvh/leaf.comp @@ -333,6 +333,14 @@ main(void) is_active = build_instance(bounds, src_ptr, dst_ptr, global_id); } +#if ALWAYS_ACTIVE + if (!is_active && args.geometry_type != VK_GEOMETRY_TYPE_INSTANCES_KHR) { + bounds.min = vec3(0.0); + bounds.max = vec3(0.0); + is_active = true; + } +#endif + DEREF(id_ptr).id = is_active ? pack_ir_node_id(dst_offset, node_type) : RADV_BVH_INVALID_NODE; uvec4 ballot = subgroupBallot(is_active); diff --git a/src/amd/vulkan/bvh/meson.build b/src/amd/vulkan/bvh/meson.build index 244bce3195e..d9ed237e079 100644 --- a/src/amd/vulkan/bvh/meson.build +++ b/src/amd/vulkan/bvh/meson.build @@ -53,7 +53,12 @@ bvh_shaders = [ [ 'leaf.comp', 'leaf', - [], + ['ALWAYS_ACTIVE=0'], + ], + [ + 'leaf.comp', + 'leaf_always_active', + ['ALWAYS_ACTIVE=1'], ], [ 'morton.comp', diff --git a/src/amd/vulkan/radv_acceleration_structure.c b/src/amd/vulkan/radv_acceleration_structure.c index 70b967d7e5b..9ff97bc9a8d 100644 --- a/src/amd/vulkan/radv_acceleration_structure.c +++ b/src/amd/vulkan/radv_acceleration_structure.c @@ -41,6 +41,10 @@ static const uint32_t leaf_spv[] = { #include "bvh/leaf.spv.h" }; +static const uint32_t leaf_always_active_spv[] = { +#include "bvh/leaf_always_active.spv.h" +}; + static const uint32_t morton_spv[] = { #include "bvh/morton.spv.h" }; @@ -513,9 +517,14 @@ radv_device_init_accel_struct_build_state(struct radv_device *device) if (device->meta_state.accel_struct_build.radix_sort) goto exit; - result = create_build_pipeline_spv(device, leaf_spv, sizeof(leaf_spv), sizeof(struct leaf_args), - &device->meta_state.accel_struct_build.leaf_pipeline, - &device->meta_state.accel_struct_build.leaf_p_layout); + if (device->instance->force_active_accel_struct_leaves) + result = create_build_pipeline_spv(device, leaf_always_active_spv, sizeof(leaf_always_active_spv), + sizeof(struct leaf_args), &device->meta_state.accel_struct_build.leaf_pipeline, + &device->meta_state.accel_struct_build.leaf_p_layout); + else + result = create_build_pipeline_spv(device, leaf_spv, sizeof(leaf_spv), sizeof(struct leaf_args), + &device->meta_state.accel_struct_build.leaf_pipeline, + &device->meta_state.accel_struct_build.leaf_p_layout); if (result != VK_SUCCESS) goto exit; diff --git a/src/amd/vulkan/radv_instance.c b/src/amd/vulkan/radv_instance.c index 14032b93a19..f7e14b5990f 100644 --- a/src/amd/vulkan/radv_instance.c +++ b/src/amd/vulkan/radv_instance.c @@ -154,6 +154,7 @@ static const driOptionDescription radv_dri_options[] = { DRI_CONF_RADV_RT_WAVE64(false) DRI_CONF_DUAL_COLOR_BLEND_BY_LOCATION(false) DRI_CONF_RADV_SSBO_NON_UNIFORM(false) + DRI_CONF_RADV_FORCE_ACTIVE_ACCEL_STRUCT_LEAVES(false) DRI_CONF_RADV_APP_LAYER() DRI_CONF_SECTION_END }; @@ -214,6 +215,9 @@ radv_init_dri_options(struct radv_instance *instance) instance->force_rt_wave64 = driQueryOptionb(&instance->dri_options, "radv_rt_wave64"); instance->dual_color_blend_by_location = driQueryOptionb(&instance->dri_options, "dual_color_blend_by_location"); + + instance->force_active_accel_struct_leaves = + driQueryOptionb(&instance->dri_options, "radv_force_active_accel_struct_leaves"); } static const struct vk_instance_extension_table radv_instance_extensions_supported = { diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 43a2bb7e6c1..1e7bdc9ab25 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -420,6 +420,7 @@ struct radv_instance { bool flush_before_timestamp_write; bool force_rt_wave64; bool dual_color_blend_by_location; + bool force_active_accel_struct_leaves; char *app_layer; }; diff --git a/src/util/00-radv-defaults.conf b/src/util/00-radv-defaults.conf index 0dcec733e52..1cbb2e087c9 100644 --- a/src/util/00-radv-defaults.conf +++ b/src/util/00-radv-defaults.conf @@ -104,6 +104,7 @@ Application bugs worked around in this file: diff --git a/src/util/driconf.h b/src/util/driconf.h index c3e6c7f5212..751279e612e 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -688,6 +688,10 @@ #define DRI_CONF_RADV_APP_LAYER() DRI_CONF_OPT_S_NODEF(radv_app_layer, "Select an application layer.") +#define DRI_CONF_RADV_FORCE_ACTIVE_ACCEL_STRUCT_LEAVES(def) \ + DRI_CONF_OPT_B(radv_force_active_accel_struct_leaves, def, \ + "Force leaf nodes of acceleration structures to be marked active.") + /** * \brief ANV specific configuration options */