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 <chadversary@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16284>
This commit is contained in:
Chad Versace 2022-05-02 12:56:24 -07:00 committed by Marge Bot
parent 683b6e8d35
commit fe3e850dfb
1 changed files with 20 additions and 0 deletions

View File

@ -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;