From fe3e850dfb2176e41ea6413b6739ae12cc4d32f7 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Mon, 2 May 2022 12:56:24 -0700 Subject: [PATCH] venus: Don't encode ignored pTessellationState The spec says that VkGraphicsPipelineCreateInfo::pTessellationState is ignored and may be an invalid pointer in some cases. When ignored, patch the pCreateInfo with `pTessellationState = NULL`, so the encoder doesn't attempt to encode an invalid pointer. Tested in Borealis, with debug build of venus, with a minimal test app that sets `.pTesselationState = 0x17`. Pre-patch, the app crashes; post-patch, the app works. Signed-off-by: Chad Versace Reviewed-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_pipeline.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/virtio/vulkan/vn_pipeline.c b/src/virtio/vulkan/vn_pipeline.c index dbab41c7272..a5b45ce5504 100644 --- a/src/virtio/vulkan/vn_pipeline.c +++ b/src/virtio/vulkan/vn_pipeline.c @@ -242,6 +242,8 @@ vn_MergePipelineCaches(VkDevice device, /* pipeline commands */ struct vn_graphics_pipeline_create_info_fix { + bool ignore_tessellation_state; + /* Ignore the following: * pViewportState * pMultisampleState @@ -269,6 +271,21 @@ vn_fix_graphics_pipeline_create_info( struct vn_graphics_pipeline_create_info_fix fix = { 0 }; bool any_fix = false; + VkShaderStageFlags stages = 0; + for (uint32_t i = 0; i < info->stageCount; ++i) { + stages |= info->pStages[i].stage; + } + + /* Fix pTessellationState? + * VUID-VkGraphicsPipelineCreateInfo-pStages-00731 + */ + if (info->pTessellationState && + (!(stages & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) || + !(stages & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT))) { + fix.ignore_tessellation_state = true; + any_fix = true; + } + /* FIXME: Conditions for ignoring pDepthStencilState and * pColorBlendState miss some cases that depend on the render pass. Make * them agree with the VUIDs. @@ -311,6 +328,9 @@ vn_fix_graphics_pipeline_create_info( VkGraphicsPipelineCreateInfo *info = &infos[i]; struct vn_graphics_pipeline_create_info_fix fix = fixes[i]; + if (fix.ignore_tessellation_state) + info->pTessellationState = NULL; + if (fix.ignore_raster_dedicated_states) { info->pViewportState = NULL; info->pMultisampleState = NULL;