From d7d098679b40c0aa5bf0b01bda68c05dbae4880e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 26 Apr 2023 15:26:37 -0400 Subject: [PATCH] asahi: Fix depth load/store flags If depth_writemask is set, we need to write depth regardless of whether we run the depth test, to write out the fixed-function fragment depth. This will matter when we start honouring these flags. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_state.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 870f77b13cb..3931b6b595b 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -230,7 +230,11 @@ agx_create_zsa_state(struct pipe_context *ctx, so->base = *state; - /* Z func can be used as-is */ + /* Handle the enable flag */ + enum pipe_compare_func depth_func = + state->depth_enabled ? state->depth_func : PIPE_FUNC_ALWAYS; + + /* Z func can otherwise be used as-is */ STATIC_ASSERT((enum agx_zs_func)PIPE_FUNC_NEVER == AGX_ZS_FUNC_NEVER); STATIC_ASSERT((enum agx_zs_func)PIPE_FUNC_LESS == AGX_ZS_FUNC_LESS); STATIC_ASSERT((enum agx_zs_func)PIPE_FUNC_EQUAL == AGX_ZS_FUNC_EQUAL); @@ -241,10 +245,7 @@ agx_create_zsa_state(struct pipe_context *ctx, STATIC_ASSERT((enum agx_zs_func)PIPE_FUNC_ALWAYS == AGX_ZS_FUNC_ALWAYS); agx_pack(&so->depth, FRAGMENT_FACE, cfg) { - cfg.depth_function = state->depth_enabled - ? ((enum agx_zs_func)state->depth_func) - : AGX_ZS_FUNC_ALWAYS; - + cfg.depth_function = (enum agx_zs_func)depth_func; cfg.disable_depth_write = !state->depth_writemask; } @@ -257,15 +258,12 @@ agx_create_zsa_state(struct pipe_context *ctx, so->back_stencil = so->front_stencil; } - if (state->depth_enabled) { - if (state->depth_func != PIPE_FUNC_NEVER && - state->depth_func != PIPE_FUNC_ALWAYS) { + if (depth_func != PIPE_FUNC_NEVER && depth_func != PIPE_FUNC_ALWAYS) + so->load |= PIPE_CLEAR_DEPTH; - so->load |= PIPE_CLEAR_DEPTH; - } - - if (state->depth_writemask) - so->store |= PIPE_CLEAR_DEPTH; + if (state->depth_writemask) { + so->load |= PIPE_CLEAR_DEPTH; + so->store |= PIPE_CLEAR_DEPTH; } if (state->stencil[0].enabled) {