radv: Add driconf to always drain waves before writing timestamps

UE4's Vulkan backend uses vkCmdWriteTimestamp with TOP_OF_PIPE
to measure how long a workload took in the GPU Benchmark. This is wrong
and writes the timestamp before the workload is actually finished,
making it seem like the GPU is much faster than it actually is.
This caused subsequent benchmark passes to contain way too big workloads,
which caused soft hangs on slower GPUs.

Fixes GPU hangs with Splitgate during automatic settings configuration.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22823>
This commit is contained in:
Friedrich Vock 2023-05-03 12:20:39 +02:00 committed by Marge Bot
parent 284e604872
commit 0b251d4362
5 changed files with 15 additions and 0 deletions

View file

@ -144,6 +144,7 @@ static const driOptionDescription radv_dri_options[] = {
DRI_CONF_RADV_ENABLE_UNIFIED_HEAP_ON_APU(false)
DRI_CONF_RADV_TEX_NON_UNIFORM(false)
DRI_CONF_RADV_RT(false)
DRI_CONF_RADV_FLUSH_BEFORE_TIMESTAMP_WRITE(false)
DRI_CONF_RADV_APP_LAYER()
DRI_CONF_SECTION_END
};
@ -202,6 +203,9 @@ radv_init_dri_options(struct radv_instance *instance)
instance->tex_non_uniform = driQueryOptionb(&instance->dri_options, "radv_tex_non_uniform");
instance->app_layer = driQueryOptionstr(&instance->dri_options, "radv_app_layer");
instance->flush_before_timestamp_write =
driQueryOptionb(&instance->dri_options, "radv_flush_before_timestamp_write");
}
static const struct vk_instance_extension_table radv_instance_extensions_supported = {

View file

@ -413,6 +413,7 @@ struct radv_instance {
bool flush_before_query_copy;
bool enable_unified_heap_on_apu;
bool tex_non_uniform;
bool flush_before_timestamp_write;
char *app_layer;
};

View file

@ -2145,6 +2145,11 @@ radv_CmdWriteTimestamp2(VkCommandBuffer commandBuffer, VkPipelineStageFlags2 sta
radv_cs_add_buffer(cmd_buffer->device->ws, cs, pool->bo);
if (cmd_buffer->device->instance->flush_before_timestamp_write) {
/* Make sure previously launched waves have finished */
cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_PS_PARTIAL_FLUSH | RADV_CMD_FLAG_CS_PARTIAL_FLUSH;
}
si_emit_cache_flush(cmd_buffer);
int num_queries = 1;

View file

@ -54,6 +54,7 @@ Application bugs worked around in this file:
<engine engine_name_match="^UnrealEngine"> <!-- UE4/5 Vulkan RHI -->
<option name="radv_flush_before_query_copy" value="true" />
<option name="radv_flush_before_timestamp_write" value="true" />
</engine>
<engine engine_name_match="DXVK_NvRemix">

View file

@ -627,6 +627,10 @@
DRI_CONF_OPT_B(radv_rt, def, \
"Expose support for VK_KHR_ray_tracing_pipeline")
#define DRI_CONF_RADV_FLUSH_BEFORE_TIMESTAMP_WRITE(def) \
DRI_CONF_OPT_B(radv_flush_before_timestamp_write, def, \
"Wait for previous commands to finish before writing timestamps")
#define DRI_CONF_RADV_APP_LAYER() DRI_CONF_OPT_S_NODEF(radv_app_layer, "Select an application layer.")
/**