From 51dd480f790e32a2eaaec9627c21360346b1b0e2 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 16 Apr 2024 14:37:47 -0400 Subject: [PATCH] lavapipe: disable stencil test if no stencil attachment stencil test must not be enabled if there is no stencil attachment fixes dEQP-VK.pipeline.*.stencil.no_stencil_att.dynamic_rendering.* fixes #10990 cc: mesa-stable Part-of: (cherry picked from commit fc691d9f37105e8da7aff45036a5ad1397d945cf) --- .pick_status.json | 2 +- src/gallium/frontends/lavapipe/lvp_execute.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index c09d3b74f85..d9c65277993 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1614,7 +1614,7 @@ "description": "lavapipe: disable stencil test if no stencil attachment", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c index f47997171a6..85dd46d04b8 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -88,6 +88,7 @@ struct rendering_state { bool blend_dirty; bool rs_dirty; bool dsa_dirty; + bool dsa_no_stencil; bool stencil_ref_dirty; bool clip_state_dirty; bool blend_color_dirty; @@ -470,8 +471,16 @@ static void emit_state(struct rendering_state *state) } if (state->dsa_dirty) { + bool s0_enabled = state->dsa_state.stencil[0].enabled; + bool s1_enabled = state->dsa_state.stencil[1].enabled; + if (state->dsa_no_stencil) { + state->dsa_state.stencil[0].enabled = false; + state->dsa_state.stencil[1].enabled = false; + } cso_set_depth_stencil_alpha(state->cso, &state->dsa_state); state->dsa_dirty = false; + state->dsa_state.stencil[0].enabled = s0_enabled; + state->dsa_state.stencil[1].enabled = s1_enabled; } if (state->sample_mask_dirty) { @@ -1784,6 +1793,8 @@ handle_begin_rendering(struct vk_cmd_queue_entry *cmd, render_att_init(&state->depth_att, info->pDepthAttachment, state->poison_mem, false); render_att_init(&state->stencil_att, info->pStencilAttachment, state->poison_mem, true); + state->dsa_no_stencil = !state->stencil_att.imgv; + state->dsa_dirty = true; if (state->depth_att.imgv || state->stencil_att.imgv) { assert(state->depth_att.imgv == NULL || state->stencil_att.imgv == NULL ||