anv,driconf: Add fake non device local memory WA for Total War: Warhammer 3

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8721
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29127>
This commit is contained in:
Sviatoslav Peleshko
2024-05-09 23:19:00 +03:00
committed by Marge Bot
parent df17f2b89a
commit 94989b45a5
4 changed files with 31 additions and 0 deletions

View File

@@ -93,6 +93,7 @@ static const driOptionDescription anv_dri_options[] = {
DRI_CONF_SHADER_SPILLING_RATE(0)
DRI_CONF_OPT_B(intel_tbimr, true, "Enable TBIMR tiled rendering")
DRI_CONF_ANV_COMPRESSION_CONTROL_ENABLED(false)
DRI_CONF_ANV_FAKE_NONLOCAL_MEMORY(false)
DRI_CONF_SECTION_END
DRI_CONF_SECTION_DEBUG
@@ -2697,6 +2698,8 @@ anv_init_dri_options(struct anv_instance *instance)
driQueryOptionb(&instance->dri_options, "anv_external_memory_implicit_sync");
instance->compression_control_enabled =
driQueryOptionb(&instance->dri_options, "compression_control_enabled");
instance->anv_fake_nonlocal_memory =
driQueryOptionb(&instance->dri_options, "anv_fake_nonlocal_memory");
}
VkResult anv_CreateInstance(
@@ -2879,6 +2882,26 @@ void anv_GetPhysicalDeviceMemoryProperties(
.flags = physical_device->memory.heaps[i].flags,
};
}
/* Some games (e.g. Total War: WARHAMMER III) sometimes completely refuse
* to use memory types with VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT set.
* On iGPUs we have only device-local memory, so we must hide it
* from the flags.
*
* Additionally, TW also seems to crash if a non-local but also
* non host-visible memory is present, so we should be careful which
* memory types we hide this flag from.
*/
if (physical_device->instance->anv_fake_nonlocal_memory &&
!anv_physical_device_has_vram(physical_device)) {
for (uint32_t i = 0; i < physical_device->memory.type_count; i++) {
if (pMemoryProperties->memoryTypes[i].propertyFlags &
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
pMemoryProperties->memoryTypes[i].propertyFlags &=
~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
}
}
}
}
static void

View File

@@ -1288,6 +1288,7 @@ struct anv_instance {
bool has_fake_sparse;
bool disable_fcv;
bool compression_control_enabled;
bool anv_fake_nonlocal_memory;
/* HW workarounds */
bool no_16bit;

View File

@@ -1248,6 +1248,9 @@ TODO: document the other workarounds.
<application name="DIRT 5" executable="DIRT5.exe">
<option name="fp64_workaround_enabled" value="true" />
</application>
<application name="Total War: WARHAMMER III" executable="TotalWarhammer3">
<option name="anv_fake_nonlocal_memory" value="true" />
</application>
<!--
Disable 16-bit feature on zink and angle so that GLES mediump doesn't
lower to our inefficent 16-bit shader support. No need to do so for

View File

@@ -790,6 +790,10 @@
#define DRI_CONF_ANV_COMPRESSION_CONTROL_ENABLED(def) \
DRI_CONF_OPT_B(compression_control_enabled, def, "Enable VK_EXT_image_compression_control support")
#define DRI_CONF_ANV_FAKE_NONLOCAL_MEMORY(def) \
DRI_CONF_OPT_B(anv_fake_nonlocal_memory, def, \
"Present host-visible device-local memory types as non device-local")
/**
* \brief HASVK specific configuration options
*/