anv: fix descriptor set free
Once we start going through the free list of the descriptor set pool, we might use a free entry larger than the descriptor set we want to allocate. When we free that descriptor set, we use the size of the set rather than the size of the entry that was picked. This leads to leaks of some amount of descriptor set pool. This fix saves the size of the entry in the descriptor set so we know what amount of the pool needs to freed. v2: Don't bother adding a new size field Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com> Cc: <mesa-stable@lists.freedesktop.org> Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3324 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6084>
This commit is contained in:
committed by
Marge Bot
parent
845a50ee25
commit
1cdd161a30
@@ -850,6 +850,7 @@ anv_descriptor_pool_alloc_set(struct anv_descriptor_pool *pool,
|
||||
{
|
||||
if (size <= pool->size - pool->next) {
|
||||
*set = (struct anv_descriptor_set *) (pool->data + pool->next);
|
||||
(*set)->size = size;
|
||||
pool->next += size;
|
||||
return VK_SUCCESS;
|
||||
} else {
|
||||
@@ -860,6 +861,7 @@ anv_descriptor_pool_alloc_set(struct anv_descriptor_pool *pool,
|
||||
if (size <= entry->size) {
|
||||
*link = entry->next;
|
||||
*set = (struct anv_descriptor_set *) entry;
|
||||
(*set)->size = entry->size;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
link = &entry->next;
|
||||
@@ -979,7 +981,6 @@ anv_descriptor_set_create(struct anv_device *device,
|
||||
set->layout = layout;
|
||||
anv_descriptor_set_layout_ref(layout);
|
||||
|
||||
set->size = size;
|
||||
set->buffer_views =
|
||||
(struct anv_buffer_view *) &set->descriptors[layout->size];
|
||||
set->buffer_view_count = layout->buffer_view_count;
|
||||
|
||||
@@ -2026,6 +2026,10 @@ struct anv_descriptor_set {
|
||||
|
||||
struct anv_descriptor_pool *pool;
|
||||
struct anv_descriptor_set_layout *layout;
|
||||
|
||||
/* Amount of space occupied in the the pool by this descriptor set. It can
|
||||
* be larger than the size of the descriptor set.
|
||||
*/
|
||||
uint32_t size;
|
||||
|
||||
/* State relative to anv_descriptor_pool::bo */
|
||||
|
||||
Reference in New Issue
Block a user