Mesa (staging/20.1): anv: fix descriptor set free

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 29 11:33:13 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 03a08efb45e6f036b4875bfb9a9c66daa08a1ba1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=03a08efb45e6f036b4875bfb9a9c66daa08a1ba1

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Mon Jul 27 12:06:17 2020 +0300

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 at intel.com>
Reviewed-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Cc: <mesa-stable at lists.freedesktop.org>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3324
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6084>
(cherry picked from commit 1cdd161a30297c13908134d8d205a7a377ec807a)

---

 .pick_status.json                     | 2 +-
 src/intel/vulkan/anv_descriptor_set.c | 3 ++-
 src/intel/vulkan/anv_private.h        | 4 ++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 2c8d895d9d5..4bf75d74d5c 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -193,7 +193,7 @@
         "description": "anv: fix descriptor set free",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index d4d6294ecf8..c46be92e517 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -833,6 +833,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 {
@@ -843,6 +844,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;
@@ -960,7 +962,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;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index f73b5f053c0..0d13693788e 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1953,6 +1953,10 @@ struct anv_descriptor {
 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 */



More information about the mesa-commit mailing list