turnip: Drop references to layout of all sets on pool reset/destruction

We dropped the references only for non-host_memory_base pools.
Create a list of alive descriptor to account for all of them.

Fixes: 1b513f49 ("tu: add reference counting for descriptor set layouts")

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14235>
This commit is contained in:
Danylo Piliaiev 2022-01-27 16:04:06 +02:00 committed by Marge Bot
parent bdb8e615d1
commit da7a475138
2 changed files with 17 additions and 4 deletions

View file

@ -562,6 +562,7 @@ tu_descriptor_set_create(struct tu_device *device,
} }
tu_descriptor_set_layout_ref(layout); tu_descriptor_set_layout_ref(layout);
list_addtail(&set->pool_link, &pool->desc_sets);
*out_set = set; *out_set = set;
return VK_SUCCESS; return VK_SUCCESS;
@ -588,6 +589,8 @@ tu_descriptor_set_destroy(struct tu_device *device,
} }
} }
list_del(&set->pool_link);
vk_object_free(&device->vk, NULL, set); vk_object_free(&device->vk, NULL, set);
} }
@ -680,6 +683,8 @@ tu_CreateDescriptorPool(VkDevice _device,
pool->size = bo_size; pool->size = bo_size;
pool->max_entry_count = pCreateInfo->maxSets; pool->max_entry_count = pCreateInfo->maxSets;
list_inithead(&pool->desc_sets);
*pDescriptorPool = tu_descriptor_pool_to_handle(pool); *pDescriptorPool = tu_descriptor_pool_to_handle(pool);
return VK_SUCCESS; return VK_SUCCESS;
@ -701,8 +706,9 @@ tu_DestroyDescriptorPool(VkDevice _device,
if (!pool) if (!pool)
return; return;
for(int i = 0; i < pool->entry_count; ++i) { list_for_each_entry_safe(struct tu_descriptor_set, set,
tu_descriptor_set_layout_unref(device, pool->entries[i].set->layout); &pool->desc_sets, pool_link) {
tu_descriptor_set_layout_unref(device, set->layout);
} }
if (!pool->host_memory_base) { if (!pool->host_memory_base) {
@ -729,9 +735,11 @@ tu_ResetDescriptorPool(VkDevice _device,
TU_FROM_HANDLE(tu_device, device, _device); TU_FROM_HANDLE(tu_device, device, _device);
TU_FROM_HANDLE(tu_descriptor_pool, pool, descriptorPool); TU_FROM_HANDLE(tu_descriptor_pool, pool, descriptorPool);
for(int i = 0; i < pool->entry_count; ++i) { list_for_each_entry_safe(struct tu_descriptor_set, set,
tu_descriptor_set_layout_unref(device, pool->entries[i].set->layout); &pool->desc_sets, pool_link) {
tu_descriptor_set_layout_unref(device, set->layout);
} }
list_inithead(&pool->desc_sets);
if (!pool->host_memory_base) { if (!pool->host_memory_base) {
for(int i = 0; i < pool->entry_count; ++i) { for(int i = 0; i < pool->entry_count; ++i) {

View file

@ -658,6 +658,9 @@ struct tu_descriptor_set
{ {
struct vk_object_base base; struct vk_object_base base;
/* Link to descriptor pool's desc_sets list . */
struct list_head pool_link;
struct tu_descriptor_set_layout *layout; struct tu_descriptor_set_layout *layout;
struct tu_descriptor_pool *pool; struct tu_descriptor_pool *pool;
uint32_t size; uint32_t size;
@ -688,6 +691,8 @@ struct tu_descriptor_pool
uint8_t *host_memory_end; uint8_t *host_memory_end;
uint8_t *host_bo; uint8_t *host_bo;
struct list_head desc_sets;
uint32_t entry_count; uint32_t entry_count;
uint32_t max_entry_count; uint32_t max_entry_count;
struct tu_descriptor_pool_entry entries[0]; struct tu_descriptor_pool_entry entries[0];