radv: fix a descriptor leak with debug names and host base descriptor set
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 7 Nov 2023 09:30:43 +0000 (10:30 +0100)
committerEric Engestrom <eric@engestrom.ch>
Sat, 18 Nov 2023 21:15:12 +0000 (21:15 +0000)
vk_object_base_finish() needs to be called on the descriptor set in
order to free the debug names.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10098
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26088>
(cherry picked from commit 4239e13ff658f7e4746779b8b4c4954b9437533c)

.pick_status.json
src/amd/vulkan/radv_descriptor_set.c
src/amd/vulkan/radv_private.h

index 356f633..8d34aa8 100644 (file)
         "description": "radv: fix a descriptor leak with debug names and host base descriptor set",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null,
         "notes": null
index a0aa067..602a995 100644 (file)
@@ -691,7 +691,7 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po
          pool->entries[pool->entry_count].size = layout_size;
          pool->entries[pool->entry_count].set = set;
       } else {
-         pool->layouts[pool->entry_count] = layout;
+         pool->sets[pool->entry_count] = set;
       }
 
       pool->current_offset += layout_size;
@@ -775,7 +775,8 @@ radv_destroy_descriptor_pool(struct radv_device *device, const VkAllocationCallb
       }
    } else {
       for (uint32_t i = 0; i < pool->entry_count; ++i) {
-         vk_descriptor_set_layout_unref(&device->vk, &pool->layouts[i]->vk);
+         vk_descriptor_set_layout_unref(&device->vk, &pool->sets[i]->header.layout->vk);
+         vk_object_base_finish(&pool->sets[i]->header.base);
       }
    }
 
@@ -881,15 +882,15 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
       bo_size += 16 * MIN2(num_16byte_descriptors, pCreateInfo->maxSets);
    }
 
-   uint64_t layouts_size = 0;
+   uint64_t sets_size = 0;
 
    if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
       size += pCreateInfo->maxSets * sizeof(struct radv_descriptor_set);
       size += sizeof(struct radeon_winsys_bo *) * bo_count;
       size += sizeof(struct radv_descriptor_range) * range_count;
 
-      layouts_size = sizeof(struct radv_descriptor_set_layout *) * pCreateInfo->maxSets;
-      size += layouts_size;
+      sets_size = sizeof(struct radv_descriptor_set *) * pCreateInfo->maxSets;
+      size += sets_size;
    } else {
       size += sizeof(struct radv_descriptor_pool_entry) * pCreateInfo->maxSets;
    }
@@ -903,7 +904,7 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
    vk_object_base_init(&device->vk, &pool->base, VK_OBJECT_TYPE_DESCRIPTOR_POOL);
 
    if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
-      pool->host_memory_base = (uint8_t *)pool + sizeof(struct radv_descriptor_pool) + layouts_size;
+      pool->host_memory_base = (uint8_t *)pool + sizeof(struct radv_descriptor_pool) + sets_size;
       pool->host_memory_ptr = pool->host_memory_base;
       pool->host_memory_end = (uint8_t *)pool + size;
    }
@@ -975,7 +976,8 @@ radv_ResetDescriptorPool(VkDevice _device, VkDescriptorPool descriptorPool, VkDe
       }
    } else {
       for (uint32_t i = 0; i < pool->entry_count; ++i) {
-         vk_descriptor_set_layout_unref(&device->vk, &pool->layouts[i]->vk);
+         vk_descriptor_set_layout_unref(&device->vk, &pool->sets[i]->header.layout->vk);
+         vk_object_base_finish(&pool->sets[i]->header.base);
       }
    }
 
index 5eb9102..56d0ad2 100644 (file)
@@ -1201,7 +1201,7 @@ struct radv_descriptor_pool {
    uint32_t max_entry_count;
 
    union {
-      struct radv_descriptor_set_layout *layouts[0];
+      struct radv_descriptor_set *sets[0];
       struct radv_descriptor_pool_entry entries[0];
    };
 };