From bb9efa527afccce2d40d196fe3b0ffa2460ea4d5 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 6 May 2021 16:09:10 -0400 Subject: [PATCH] zink: split stencil ref changes to separate dirty flag the values here are for the cmdbuf, not the pipeline, so they should always be updated regardless of what the current dsa state uses Reviewed-by: Hoe Hao Cheng Part-of: --- src/gallium/drivers/zink/zink_context.c | 3 ++- src/gallium/drivers/zink/zink_context.h | 1 + src/gallium/drivers/zink/zink_draw.c | 20 ++++++++------------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 6001264341b..dabb6f0370d 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -1362,7 +1362,7 @@ zink_set_stencil_ref(struct pipe_context *pctx, { struct zink_context *ctx = zink_context(pctx); ctx->stencil_ref = ref; - ctx->dsa_state_changed |= !!ctx->dsa_state; + ctx->stencil_ref_changed = true; } static void @@ -1803,6 +1803,7 @@ flush_batch(struct zink_context *ctx, bool sync) ctx->vp_state_changed = true; ctx->scissor_changed = true; ctx->rast_state_changed = true; + ctx->stencil_ref_changed = true; ctx->dsa_state_changed = true; } } diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index 1d89c4e176d..02f775ec9a3 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -168,6 +168,7 @@ struct zink_context { struct zink_depth_stencil_alpha_state *dsa_state; bool rast_state_changed : 1; bool dsa_state_changed : 1; + bool stencil_ref_changed : 1; struct hash_table desc_set_layouts[ZINK_DESCRIPTOR_TYPES]; bool pipeline_changed[2]; //gfx, compute diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index 5a6fcfc0937..3dceab1078f 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -583,19 +583,15 @@ zink_draw_vbo(struct pipe_context *pctx, debug_printf("BUG: wide lines not supported, needs fallback!"); } - if (pipeline_changed || ctx->dsa_state_changed) { - if (dsa_state->base.stencil[0].enabled) { - if (dsa_state->base.stencil[1].enabled) { - vkCmdSetStencilReference(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_BIT, - ctx->stencil_ref.ref_value[0]); - vkCmdSetStencilReference(batch->state->cmdbuf, VK_STENCIL_FACE_BACK_BIT, - ctx->stencil_ref.ref_value[1]); - } else - vkCmdSetStencilReference(batch->state->cmdbuf, - VK_STENCIL_FACE_FRONT_AND_BACK, - ctx->stencil_ref.ref_value[0]); - } + if (ctx->stencil_ref_changed) { + vkCmdSetStencilReference(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_BIT, + ctx->stencil_ref.ref_value[0]); + vkCmdSetStencilReference(batch->state->cmdbuf, VK_STENCIL_FACE_BACK_BIT, + ctx->stencil_ref.ref_value[1]); + ctx->stencil_ref_changed = false; + } + if (pipeline_changed || ctx->dsa_state_changed) { if (screen->info.have_EXT_extended_dynamic_state) { screen->vk.CmdSetDepthBoundsTestEnableEXT(batch->state->cmdbuf, dsa_state->hw_state.depth_bounds_test); if (dsa_state->hw_state.depth_bounds_test)