zink: only set stencil-ref for back if two-sided

Otherwise, we want to set both front and back to the same state.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6853>
This commit is contained in:
Erik Faye-Lund 2020-09-24 22:25:28 +02:00 committed by Marge Bot
parent 4b2525b68d
commit cbef2dc7d3

View file

@ -210,6 +210,7 @@ zink_draw_vbo(struct pipe_context *pctx,
struct zink_context *ctx = zink_context(pctx); struct zink_context *ctx = zink_context(pctx);
struct zink_screen *screen = zink_screen(pctx->screen); struct zink_screen *screen = zink_screen(pctx->screen);
struct zink_rasterizer_state *rast_state = ctx->rast_state; struct zink_rasterizer_state *rast_state = ctx->rast_state;
struct zink_depth_stencil_alpha_state *dsa_state = ctx->dsa_state;
struct zink_so_target *so_target = zink_so_target(dinfo->count_from_stream_output); struct zink_so_target *so_target = zink_so_target(dinfo->count_from_stream_output);
VkBuffer counter_buffers[PIPE_MAX_SO_OUTPUTS]; VkBuffer counter_buffers[PIPE_MAX_SO_OUTPUTS];
VkDeviceSize counter_buffer_offsets[PIPE_MAX_SO_OUTPUTS] = {}; VkDeviceSize counter_buffer_offsets[PIPE_MAX_SO_OUTPUTS] = {};
@ -413,8 +414,17 @@ zink_draw_vbo(struct pipe_context *pctx,
debug_printf("BUG: wide lines not supported, needs fallback!"); debug_printf("BUG: wide lines not supported, needs fallback!");
} }
vkCmdSetStencilReference(batch->cmdbuf, VK_STENCIL_FACE_FRONT_BIT, ctx->stencil_ref.ref_value[0]); if (dsa_state->base.stencil[0].enabled) {
vkCmdSetStencilReference(batch->cmdbuf, VK_STENCIL_FACE_BACK_BIT, ctx->stencil_ref.ref_value[1]); if (dsa_state->base.stencil[1].enabled) {
vkCmdSetStencilReference(batch->cmdbuf, VK_STENCIL_FACE_FRONT_BIT,
ctx->stencil_ref.ref_value[0]);
vkCmdSetStencilReference(batch->cmdbuf, VK_STENCIL_FACE_BACK_BIT,
ctx->stencil_ref.ref_value[1]);
} else
vkCmdSetStencilReference(batch->cmdbuf,
VK_STENCIL_FACE_FRONT_AND_BACK,
ctx->stencil_ref.ref_value[0]);
}
if (depth_bias) if (depth_bias)
vkCmdSetDepthBias(batch->cmdbuf, rast_state->offset_units, rast_state->offset_clamp, rast_state->offset_scale); vkCmdSetDepthBias(batch->cmdbuf, rast_state->offset_units, rast_state->offset_clamp, rast_state->offset_scale);