lavapipe: fix descriptor set layout reference counting in layout merge

When taking the descriptor set layouts from the pipeline layout, make
sure to take references

Fixes: d4d5a7abba ("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>
This commit is contained in:
Dave Airlie
2023-01-12 06:44:19 +10:00
committed by Marge Bot
parent abd7ea2a88
commit 20902d1ed6

View File

@@ -681,6 +681,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
@@ -703,8 +707,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);