Module: Mesa
Branch: main
Commit: b7bfba59830a9dadbab0538dccf926816cb43880
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7bfba59830a9dadbab0538dccf926816cb43880

Author: Dave Airlie <[email protected]>
Date:   Thu Sep 23 12:48:57 2021 +1000

lavapipe: don't access pColorBlendState when not legal

This state isn't valid unless some conditions are met.

Fixes VK-GL-CTS
dEQP-VK.api.pipeline.pipeline_invalid_pointers_unused_structs.graphics

Fixes: 578190c0fedd ("lavapipe: implement VK_EXT_color_write_enable")

Reviewed-By: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12984>

---

 src/gallium/frontends/lavapipe/lvp_pipeline.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c 
b/src/gallium/frontends/lavapipe/lvp_pipeline.c
index 012ac0bd048..6747055c81a 100644
--- a/src/gallium/frontends/lavapipe/lvp_pipeline.c
+++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c
@@ -833,7 +833,11 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
    } else
       pipeline->line_rectangular = true;
 
-   if (!dynamic_state_contains(pipeline->graphics_create_info.pDynamicState, 
VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT)) {
+   bool rasterization_disabled = 
!dynamic_state_contains(pipeline->graphics_create_info.pDynamicState, 
VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) &&
+      
pipeline->graphics_create_info.pRasterizationState->rasterizerDiscardEnable;
+   LVP_FROM_HANDLE(lvp_render_pass, pass, 
pipeline->graphics_create_info.renderPass);
+   if (!dynamic_state_contains(pipeline->graphics_create_info.pDynamicState, 
VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT) &&
+       !rasterization_disabled && pass->has_color_attachment) {
       const VkPipelineColorWriteCreateInfoEXT *cw_state =
          vk_find_struct_const(pCreateInfo->pColorBlendState, 
PIPELINE_COLOR_WRITE_CREATE_INFO_EXT);
       if (cw_state) {

Reply via email to