From 24c0aa3a93eeab2a0700fb3e1b60c3087e0d54d0 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:11:53 -0600 Subject: [PATCH] nvk: Use max alignment for descriptor pool sizes Since we only know the number of each descriptor type and not their groupings, we don't know how alignments will compound. Figure out the maximum alignment and then use that for everything to ensure that, no matter how they're combined, we always have enough room. Part-of: --- src/nouveau/vulkan/nvk_descriptor_set.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/nouveau/vulkan/nvk_descriptor_set.c b/src/nouveau/vulkan/nvk_descriptor_set.c index ca214be..b1cf00a 100644 --- a/src/nouveau/vulkan/nvk_descriptor_set.c +++ b/src/nouveau/vulkan/nvk_descriptor_set.c @@ -270,6 +270,7 @@ nvk_CreateDescriptorPool(VkDevice _device, vk_find_struct_const(pCreateInfo->pNext, MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE); + uint32_t max_align = 0; for (unsigned i = 0; i < pCreateInfo->poolSizeCount; ++i) { const VkMutableDescriptorTypeListVALVE *type_list = NULL; if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) { @@ -281,7 +282,21 @@ nvk_CreateDescriptorPool(VkDevice _device, uint32_t stride, align; nvk_descriptor_stride_align_for_type(pCreateInfo->pPoolSizes[i].type, type_list, &stride, &align); - bo_size += MAX2(stride, align) * + max_align = MAX2(max_align, align); + } + + for (unsigned i = 0; i < pCreateInfo->poolSizeCount; ++i) { + const VkMutableDescriptorTypeListVALVE *type_list = NULL; + if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) { + assert(mutable_info != NULL); + assert(i <= mutable_info->mutableDescriptorTypeListCount); + type_list = &mutable_info->pMutableDescriptorTypeLists[i]; + } + + uint32_t stride, align; + nvk_descriptor_stride_align_for_type(pCreateInfo->pPoolSizes[i].type, + type_list, &stride, &align); + bo_size += MAX2(stride, max_align) * pCreateInfo->pPoolSizes[i].descriptorCount; } -- 2.7.4