From 2454531de49848bbeb5913043d09f5ce18c533f9 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 12 Jul 2022 17:14:31 -0400 Subject: [PATCH] panfrost: Add zsa->zs_always_passes flag If we know ahead-of-time that depth/stencil testing will always pass, it's better to use weak_early than force_early. However, if depth/stencil testing could fail (discarding pixels), we'd rather use force_early. Determine which case we're in at CSO create time. Signed-off-by: Alyssa Rosenzweig Cc: mesa-stable Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 258e6f7c3c3..ce5d9ac93e1 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -65,6 +65,11 @@ struct panfrost_zsa_state { /* Is any depth, stencil, or alpha testing enabled? */ bool enabled; + /* Does the depth and stencil tests always pass? This ignores write + * masks, we are only interested in whether pixels may be killed. + */ + bool zs_always_passes; + #if PAN_ARCH <= 7 /* Prepacked words from the RSD */ struct mali_multisample_misc_packed rsd_depth; @@ -4362,6 +4367,21 @@ pan_pipe_to_stencil(const struct pipe_stencil_state *in, } #endif +static bool +pipe_zs_always_passes(const struct pipe_depth_stencil_alpha_state *zsa) +{ + if (zsa->depth_enabled && zsa->depth_func != PIPE_FUNC_ALWAYS) + return false; + + if (zsa->stencil[0].enabled && zsa->stencil[0].func != PIPE_FUNC_ALWAYS) + return false; + + if (zsa->stencil[1].enabled && zsa->stencil[1].func != PIPE_FUNC_ALWAYS) + return false; + + return true; +} + static void * panfrost_create_depth_stencil_state(struct pipe_context *pipe, const struct pipe_depth_stencil_alpha_state *zsa) @@ -4428,6 +4448,8 @@ panfrost_create_depth_stencil_state(struct pipe_context *pipe, so->enabled = zsa->stencil[0].enabled || (zsa->depth_enabled && zsa->depth_func != PIPE_FUNC_ALWAYS); + so->zs_always_passes = pipe_zs_always_passes(zsa); + /* TODO: Bounds test should be easy */ assert(!zsa->depth_bounds_test);