anv, hasvk: pMutableDescriptorTypeLists can be out of range on pool creation

The spec for vkCreateDescriptorPool says:
   If VkMutableDescriptorTypeCreateInfoEXT does not exist in the pNext
   chain, or VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[i]
   is out of range, the descriptor pool allocates enough memory to be
   able to allocate a VK_DESCRIPTOR_TYPE_MUTABLE_EXT descriptor with any
   supported VkDescriptorType as a mutable descriptor.

So check that mutableDescriptorTypeListCount is in range of the binding
we are asking for instead of just 0.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28031>
This commit is contained in:
Iván Briano 2024-03-06 17:14:33 -08:00 committed by Marge Bot
parent 0e1862a2ab
commit d039764410
2 changed files with 4 additions and 4 deletions

View file

@ -237,7 +237,7 @@ anv_descriptor_data_for_mutable_type(const struct anv_physical_device *device,
{
enum anv_descriptor_data desc_data = 0;
if (!mutable_info || mutable_info->mutableDescriptorTypeListCount == 0) {
if (!mutable_info || mutable_info->mutableDescriptorTypeListCount <= binding) {
for(VkDescriptorType i = 0; i <= VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; i++) {
if (i == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC ||
i == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
@ -356,7 +356,7 @@ anv_descriptor_size_for_mutable_type(const struct anv_physical_device *device,
*out_sampler_stride = 0;
if (!mutable_info ||
mutable_info->mutableDescriptorTypeListCount == 0 ||
mutable_info->mutableDescriptorTypeListCount <= binding ||
binding >= mutable_info->mutableDescriptorTypeListCount) {
for(VkDescriptorType i = 0; i <= VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; i++) {

View file

@ -123,7 +123,7 @@ anv_descriptor_data_for_mutable_type(const struct anv_physical_device *device,
{
enum anv_descriptor_data desc_data = 0;
if (!mutable_info || mutable_info->mutableDescriptorTypeListCount == 0) {
if (!mutable_info || mutable_info->mutableDescriptorTypeListCount <= binding) {
for(VkDescriptorType i = 0; i <= VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; i++) {
if (i == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC ||
i == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
@ -209,7 +209,7 @@ anv_descriptor_size_for_mutable_type(const struct anv_physical_device *device,
{
unsigned size = 0;
if (!mutable_info || mutable_info->mutableDescriptorTypeListCount == 0) {
if (!mutable_info || mutable_info->mutableDescriptorTypeListCount <= binding) {
for(VkDescriptorType i = 0; i <= VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; i++) {
if (i == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC ||