Add the iub binding count tracking

Signed-off-by: Dawn Han <dawnhan@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16699>
This commit is contained in:
Dawn Han 2022-06-30 00:33:33 +00:00 committed by Marge Bot
parent 6bd8dda57b
commit abae9d4831
2 changed files with 21 additions and 0 deletions

View File

@ -306,6 +306,9 @@ vn_CreateDescriptorPool(VkDevice device,
pool->max.set_count = pCreateInfo->maxSets;
if (iub_info)
pool->max.iub_binding_count = iub_info->maxInlineUniformBlockBindings;
for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++) {
const VkDescriptorPoolSize *pool_size = &pCreateInfo->pPoolSizes[i];
const uint32_t type_index = vn_descriptor_type_index(pool_size->type);
@ -385,6 +388,20 @@ vn_descriptor_pool_alloc_descriptors(
? last_binding_descriptor_count
: layout->bindings[i].count;
/* Allocation may fail if a call to vkAllocateDescriptorSets would cause
* the total number of inline uniform block bindings allocated from the
* pool to exceed the value of
* VkDescriptorPoolInlineUniformBlockCreateInfo::maxInlineUniformBlockBindings
* used to create the descriptor pool.
*/
if (type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK) {
if (++pool->used.iub_binding_count > pool->max.iub_binding_count) {
/* restore pool state before this allocation */
pool->used = recovery;
return false;
}
}
const uint32_t type_index = vn_descriptor_type_index(type);
pool->used.descriptor_counts[type_index] += count;
@ -415,6 +432,9 @@ vn_descriptor_pool_free_descriptors(
pool->used.descriptor_counts[vn_descriptor_type_index(
layout->bindings[i].type)] -= count;
if (layout->bindings[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK)
--pool->used.iub_binding_count;
}
--pool->used.set_count;

View File

@ -60,6 +60,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_set_layout,
struct vn_descriptor_pool_state {
uint32_t set_count;
uint32_t iub_binding_count;
uint32_t descriptor_counts[VN_NUM_DESCRIPTOR_TYPES];
};