diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c index 7b592d8b90c..d89049807d0 100644 --- a/src/intel/vulkan/anv_descriptor_set.c +++ b/src/intel/vulkan/anv_descriptor_set.c @@ -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. diff --git a/src/intel/vulkan/anv_instance.c b/src/intel/vulkan/anv_instance.c index 1205b6311ae..e63aa9e873f 100644 --- a/src/intel/vulkan/anv_instance.c +++ b/src/intel/vulkan/anv_instance.c @@ -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) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 90c97d3cc9d..2a065651828 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -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; diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index 39712cef38b..635b2193bc1 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -1272,6 +1272,9 @@ TODO: document the other workarounds. + + diff --git a/src/util/driconf.h b/src/util/driconf.h index 769d2dfd7d5..0c85305d171 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -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 */