From f5d4242928303680fdf96d454bd3b9333ee25ccc Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Thu, 14 Mar 2024 22:18:02 +0100 Subject: [PATCH] v3dv: assume that rasterization state can be NULL So far to check if rasterization discard is enabled or not we assumed that rasterization state struct was never NULL. However, as this will change with VK_EXT_extended_dynamic_state3, it can be a good idea just to assume it can be NULL, so adding the check too. Reviewed-by: Iago Toral Quiroga Signed-off-by: Juan A. Suarez Romero Part-of: --- src/broadcom/vulkan/v3dv_pipeline.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index ab8e86b6ef1..7bf4326125a 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -1140,6 +1140,7 @@ pipeline_populate_v3d_fs_key(struct v3d_fs_key *key, PIPE_LOGICOP_COPY; const bool raster_enabled = + pCreateInfo->pRasterizationState && !pCreateInfo->pRasterizationState->rasterizerDiscardEnable; /* Multisample rasterization state must be ignored if rasterization @@ -1950,6 +1951,7 @@ pipeline_populate_graphics_key(struct v3dv_pipeline *pipeline, memset(key, 0, sizeof(*key)); const bool raster_enabled = + pCreateInfo->pRasterizationState && !pCreateInfo->pRasterizationState->rasterizerDiscardEnable; const VkPipelineInputAssemblyStateCreateInfo *ia_info = @@ -2886,6 +2888,7 @@ pipeline_init(struct v3dv_pipeline *pipeline, * ignored. */ const bool raster_enabled = + pCreateInfo->pRasterizationState && !pCreateInfo->pRasterizationState->rasterizerDiscardEnable; const VkPipelineViewportStateCreateInfo *vp_info = @@ -2898,13 +2901,13 @@ pipeline_init(struct v3dv_pipeline *pipeline, raster_enabled ? pCreateInfo->pRasterizationState : NULL; const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT *pv_info = - rs_info ? vk_find_struct_const( + raster_enabled ? vk_find_struct_const( rs_info->pNext, PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT) : NULL; const VkPipelineRasterizationLineStateCreateInfoEXT *ls_info = - rs_info ? vk_find_struct_const( + raster_enabled ? vk_find_struct_const( rs_info->pNext, PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT) : NULL; @@ -2920,13 +2923,13 @@ pipeline_init(struct v3dv_pipeline *pipeline, PIPELINE_COLOR_WRITE_CREATE_INFO_EXT) : NULL; - if (vp_info) { - const VkPipelineViewportDepthClipControlCreateInfoEXT *depth_clip_control = - vk_find_struct_const(vp_info->pNext, - PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT); - if (depth_clip_control) - pipeline->negative_one_to_one = depth_clip_control->negativeOneToOne; - } + const VkPipelineViewportDepthClipControlCreateInfoEXT *depth_clip_control = + vp_info ? vk_find_struct_const(vp_info->pNext, + PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT) : + NULL; + + if (depth_clip_control) + pipeline->negative_one_to_one = depth_clip_control->negativeOneToOne; pipeline_init_dynamic_state(pipeline, pCreateInfo->pDynamicState,