radv: Implement radv_flush_before_query_copy to workaround UE Vulkan bugs.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5740

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14208>
(cherry picked from commit abc4eda846)
This commit is contained in:
Tatsuyuki Ishi 2022-05-10 14:03:03 +09:00 committed by Dylan Baker
parent 661d8de303
commit 25f9046ccd
6 changed files with 21 additions and 1 deletions

View file

@ -886,7 +886,7 @@
"description": "radv: Implement radv_flush_before_query_copy to workaround UE Vulkan bugs.",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -52,6 +52,10 @@ Application bugs worked around in this file:
<option name="radv_disable_tc_compat_htile_general" value="true" />
</engine>
<engine engine_name_match="^UnrealEngine"> <!-- UE4/5 Vulkan RHI -->
<option name="radv_flush_before_query_copy" value="true" />
</engine>
<!-- Game workarounds -->
<application name="Shadow Of The Tomb Raider (Native)" application_name_match="ShadowOfTheTomb">
<option name="radv_report_llvm9_version_string" value="true" />

View file

@ -1038,6 +1038,7 @@ static const driOptionDescription radv_dri_options[] = {
DRI_CONF_RADV_DISABLE_ANISO_SINGLE_LEVEL(false)
DRI_CONF_RADV_DISABLE_SINKING_LOAD_INPUT_FS(false)
DRI_CONF_RADV_DGC(false)
DRI_CONF_RADV_FLUSH_BEFORE_QUERY_COPY(false)
DRI_CONF_SECTION_END
};
// clang-format on
@ -1086,6 +1087,9 @@ radv_init_dri_options(struct radv_instance *instance)
instance->disable_sinking_load_input_fs =
driQueryOptionb(&instance->dri_options, "radv_disable_sinking_load_input_fs");
instance->flush_before_query_copy =
driQueryOptionb(&instance->dri_options, "radv_flush_before_query_copy");
}
VKAPI_ATTR VkResult VKAPI_CALL

View file

@ -370,6 +370,7 @@ struct radv_instance {
bool disable_aniso_single_level;
bool zero_vram;
bool disable_sinking_load_input_fs;
bool flush_before_query_copy;
};
VkResult radv_init_wsi(struct radv_physical_device *physical_device);

View file

@ -1501,6 +1501,12 @@ radv_CmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPoo
radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, pool->bo);
radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, dst_buffer->bo);
/* Workaround engines that forget to properly specify WAIT_BIT because some driver implicitly
* synchronizes before query copy.
*/
if (cmd_buffer->device->instance->flush_before_query_copy)
cmd_buffer->state.flush_bits |= cmd_buffer->active_query_flush_bits;
/* From the Vulkan spec 1.1.108:
*
* "vkCmdCopyQueryPoolResults is guaranteed to see the effect of

View file

@ -582,6 +582,11 @@
DRI_CONF_OPT_B(radv_dgc, def, \
"Expose an experimental implementation of VK_NV_device_generated_commands")
#define DRI_CONF_RADV_FLUSH_BEFORE_QUERY_COPY(def) \
DRI_CONF_OPT_B( \
radv_flush_before_query_copy, def, \
"Wait for timestamps to be written before a query copy command")
/**
* \brief ANV specific configuration options
*/