From b94553dbb3d731f7b61d98e2ee91f6465469326a Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Wed, 14 Jun 2023 18:49:40 -0400 Subject: [PATCH] Allow both renderPass and VkPipelineRenderingCreateInfo to be missing. This avoids crashes in CTS when creating a graphics pipeline. --- MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm index 39b68489..f8142936 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm @@ -378,7 +378,10 @@ id MVKGraphicsPipeline::getTessVertexStageIndex32State( #pragma mark Construction -// Extracts and returns a VkPipelineRenderingCreateInfo from the renderPass or pNext chain of pCreateInfo, or returns null if not found +// Extracts and returns a VkPipelineRenderingCreateInfo from the renderPass or pNext +// chain of pCreateInfo, or returns an empty struct if neither of those are found. +// Although the Vulkan spec is vague and unclear, there are CTS that set both renderPass +// and VkPipelineRenderingCreateInfo to null in VkGraphicsPipelineCreateInfo. static const VkPipelineRenderingCreateInfo* getRenderingCreateInfo(const VkGraphicsPipelineCreateInfo* pCreateInfo) { if (pCreateInfo->renderPass) { return ((MVKRenderPass*)pCreateInfo->renderPass)->getSubpass(pCreateInfo->subpass)->getPipelineRenderingCreateInfo(); @@ -389,7 +392,8 @@ static const VkPipelineRenderingCreateInfo* getRenderingCreateInfo(const VkGraph default: break; } } - return nullptr; + static VkPipelineRenderingCreateInfo emptyRendInfo = { .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO }; + return &emptyRendInfo; } MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device,