lavapipe: fix descriptor set layout reference counting in layout merge
authorDave Airlie <airlied@redhat.com>
Wed, 11 Jan 2023 20:44:19 +0000 (06:44 +1000)
committerEric Engestrom <eric@engestrom.ch>
Thu, 26 Jan 2023 15:40:29 +0000 (15:40 +0000)
When taking the descriptor set layouts from the pipeline layout, make
sure to take references

Fixes: d4d5a7abba7a ("lavapipe: implement EXT_graphics_pipeline_library")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20630>
(cherry picked from commit 20902d1ed685e97e135f4a16531793ddb7b4db69)

.pick_status.json
src/gallium/frontends/lavapipe/lvp_pipeline.c

index d0c6373..04385e0 100644 (file)
         "description": "lavapipe: fix descriptor set layout reference counting in layout merge",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "d4d5a7abba7a17fc31921a63c135561f74b87254"
     },
index 87d9da5..58d19c8 100644 (file)
@@ -688,6 +688,10 @@ merge_layouts(struct lvp_pipeline *dst, struct lvp_pipeline_layout *src)
       /* no layout created yet: copy onto ralloc ctx allocation for auto-free */
       dst->layout = ralloc(dst->mem_ctx, struct lvp_pipeline_layout);
       memcpy(dst->layout, src, sizeof(struct lvp_pipeline_layout));
+      for (unsigned i = 0; i < dst->layout->vk.set_count; i++) {
+         if (dst->layout->vk.set_layouts[i])
+            vk_descriptor_set_layout_ref(dst->layout->vk.set_layouts[i]);
+      }
       return;
    }
 #ifndef NDEBUG
@@ -710,8 +714,10 @@ merge_layouts(struct lvp_pipeline *dst, struct lvp_pipeline_layout *src)
    }
 #endif
    for (unsigned i = 0; i < src->vk.set_count; i++) {
-      if (!dst->layout->vk.set_layouts[i])
+      if (!dst->layout->vk.set_layouts[i]) {
          dst->layout->vk.set_layouts[i] = src->vk.set_layouts[i];
+         vk_descriptor_set_layout_ref(src->vk.set_layouts[i]);
+      }
    }
    dst->layout->vk.set_count = MAX2(dst->layout->vk.set_count,
                                     src->vk.set_count);