diff --git a/src/virtio/vulkan/vn_pipeline.c b/src/virtio/vulkan/vn_pipeline.c index 2da42c890ad..c566e288387 100644 --- a/src/virtio/vulkan/vn_pipeline.c +++ b/src/virtio/vulkan/vn_pipeline.c @@ -781,12 +781,17 @@ vn_CreateGraphicsPipelines(VkDevice device, for (uint32_t i = 0; i < createInfoCount; i++) { struct vn_pipeline *pipeline = vn_pipeline_from_handle(pPipelines[i]); + + /* Grab a refcount on the pipeline layout when needed. Take care; the + * pipeline layout may be omitted or ignored in incomplete pipelines. + */ struct vn_pipeline_layout *layout = vn_pipeline_layout_from_handle(pCreateInfos[i].layout); - if (layout->push_descriptor_set_layout || - layout->has_push_constant_ranges) { + if (layout && (layout->push_descriptor_set_layout || + layout->has_push_constant_ranges)) { pipeline->layout = vn_pipeline_layout_ref(dev, layout); } + if ((pCreateInfos[i].flags & VN_PIPELINE_CREATE_SYNC_MASK)) want_sync = true; diff --git a/src/virtio/vulkan/vn_pipeline.h b/src/virtio/vulkan/vn_pipeline.h index c3ba2ef1c4b..624eff9c5db 100644 --- a/src/virtio/vulkan/vn_pipeline.h +++ b/src/virtio/vulkan/vn_pipeline.h @@ -43,6 +43,22 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(vn_pipeline_cache, struct vn_pipeline { struct vn_object_base base; + + /** + * The VkPipelineLayout provided directly (without linking) at pipeline + * creation. Null if none was provided. + * + * We track the pipeline layout here to extend its and its children's + * lifetime, NOT because this is the actual layout used by the pipeline. + * + * WARNING. This may not be the actual layout used by the pipeline. The + * Vulkan 1.3.254 spec says: + * + * The final effective pipeline layout is effectively the union of the + * linked pipeline layouts. When binding descriptor sets for this + * pipeline, the pipeline layout used must be compatible with this + * union. + */ struct vn_pipeline_layout *layout; }; VK_DEFINE_NONDISP_HANDLE_CASTS(vn_pipeline,