Module: Mesa
Branch: main
Commit: 4239e13ff658f7e4746779b8b4c4954b9437533c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4239e13ff658f7e4746779b8b4c4954b9437533c

Author: Samuel Pitoiset <[email protected]>
Date:   Tue Nov  7 10:30:43 2023 +0100

radv: fix a descriptor leak with debug names and host base descriptor set

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26088>

---

 src/amd/vulkan/radv_descriptor_set.c | 16 +++++++++-------
 src/amd/vulkan/radv_private.h        |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/amd/vulkan/radv_descriptor_set.c 
b/src/amd/vulkan/radv_descriptor_set.c
index a0aa0673fe5..602a9952d4b 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -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);
       }
    }
 
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 0ca9b5d58e4..09d7543f8d3 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1215,7 +1215,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];
    };
 };

Reply via email to