radv/rt: Add workaround to make leaves always active

DOOM Eternal builds acceleration structures with inactive primitives and
tries to make them active in later AS updates. This is disallowed by the
spec and triggers a GPU hang. Fix the hang by working around the bug.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27034>
(cherry picked from commit a9831caa14)
This commit is contained in:
Friedrich Vock
2024-01-12 13:03:55 +01:00
committed by Eric Engestrom
parent ae7d41bd4d
commit dd6e3a1a4e
9 changed files with 38 additions and 5 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -53,7 +53,12 @@ bvh_shaders = [
[
'leaf.comp',
'leaf',
[],
['ALWAYS_ACTIVE=0'],
],
[
'leaf.comp',
'leaf_always_active',
['ALWAYS_ACTIVE=1'],
],
[
'morton.comp',

View File

@@ -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;

View File

@@ -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 = {

View File

@@ -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;
};

View File

@@ -104,6 +104,7 @@ Application bugs worked around in this file:
<application name="DOOM Eternal" application_name_match="DOOMEternal">
<option name="radv_zero_vram" value="true" />
<option name="radv_force_active_accel_struct_leaves" value="true" />
</application>
<application name="No Man's Sky" application_name_match="No Man's Sky">

View File

@@ -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
*/