anv: add a workaround for X4 Foundations

This title incorrectly tries to allocate descriptor sets larger than
the number of sampler items in the descriptor pool.

Workaround by taking other largest item count in the descriptor pool
and use that for samplers.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11795
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Lina Versace <lina@kiwitree.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32285>
This commit is contained in:
Lionel Landwerlin 2024-11-21 20:34:29 +02:00 committed by Marge Bot
parent 14d8da4c3c
commit 0fa3be44aa
5 changed files with 23 additions and 1 deletions

View File

@ -1423,6 +1423,15 @@ VkResult anv_CreateDescriptorPool(
ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_INDIRECT :
ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_DIRECT;
uint32_t max_descriptor_count = 0;
if (device->physical->instance->anv_upper_bound_descriptor_pool_sampler &&
!device->physical->indirect_descriptors) {
for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++) {
max_descriptor_count = MAX2(pCreateInfo->pPoolSizes[i].descriptorCount,
max_descriptor_count);
}
}
for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++) {
enum anv_descriptor_data desc_data =
pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT ?
@ -1449,7 +1458,8 @@ VkResult anv_CreateDescriptorPool(
uint32_t desc_data_surface_size =
desc_surface_size * pCreateInfo->pPoolSizes[i].descriptorCount;
uint32_t desc_data_sampler_size =
desc_sampler_size * pCreateInfo->pPoolSizes[i].descriptorCount;
desc_sampler_size * MAX2(max_descriptor_count,
pCreateInfo->pPoolSizes[i].descriptorCount);
/* Combined image sampler descriptors can take up to 3 slots if they
* hold a YCbCr image.

View File

@ -41,6 +41,7 @@ static const driOptionDescription anv_dri_options[] = {
DRI_CONF_ENUM(512, "512 stackids")
DRI_CONF_ENUM(1024, "1024 stackids")
DRI_CONF_ENUM(2048, "2048 stackids"))
DRI_CONF_ANV_UPPER_BOUND_DESCRIPTOR_POOL_SAMPLER(false)
DRI_CONF_SECTION_END
DRI_CONF_SECTION_DEBUG
@ -178,6 +179,9 @@ anv_init_dri_options(struct anv_instance *instance)
driQueryOptionb(&instance->dri_options, "compression_control_enabled");
instance->anv_fake_nonlocal_memory =
driQueryOptionb(&instance->dri_options, "anv_fake_nonlocal_memory");
instance->anv_upper_bound_descriptor_pool_sampler =
driQueryOptionb(&instance->dri_options,
"anv_upper_bound_descriptor_pool_sampler");
instance->stack_ids = driQueryOptioni(&instance->dri_options, "intel_stack_id");
switch (instance->stack_ids) {

View File

@ -1306,6 +1306,7 @@ struct anv_instance {
bool disable_xe2_ccs;
bool compression_control_enabled;
bool anv_fake_nonlocal_memory;
bool anv_upper_bound_descriptor_pool_sampler;
/* HW workarounds */
bool no_16bit;

View File

@ -1272,6 +1272,9 @@ TODO: document the other workarounds.
<application name="DIRT 5" executable="DIRT5.exe">
<option name="fp64_workaround_enabled" value="true" />
</application>
<application name="X4 Foundations" executable="X4">
<option name="anv_upper_bound_descriptor_pool_sampler" value="true" />
</application>
<application name="Total War: WARHAMMER III" executable="TotalWarhammer3">
<option name="anv_fake_nonlocal_memory" value="true" />
</application>

View File

@ -841,6 +841,10 @@
DRI_CONF_OPT_B(anv_fake_nonlocal_memory, def, \
"Present host-visible device-local memory types as non device-local")
#define DRI_CONF_ANV_UPPER_BOUND_DESCRIPTOR_POOL_SAMPLER(def) \
DRI_CONF_OPT_B(anv_upper_bound_descriptor_pool_sampler, def, \
"Overallocate samplers in descriptor pools to workaround app bug")
/**
* \brief HASVK specific configuration options
*/