Mesa (main): etnaviv: switch depth mode when linear PE is used

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 28 20:22:58 UTC 2022


Module: Mesa
Branch: main
Commit: 58313f3257b338928a8ae4ea375eedb50accf2bb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=58313f3257b338928a8ae4ea375eedb50accf2bb

Author: Lucas Stach <l.stach at pengutronix.de>
Date:   Thu Jun 23 20:17:54 2022 +0200

etnaviv: switch depth mode when linear PE is used

Early depth test is broken when the linear render target mode is used
and depth is written from the PE stage. It seems RA and PE disagree
about the cache layout in that case, so the RA sees unwritten/invalid
depth cache lines leading to random depth test fails. Early test works
fine if depth is written from the RA stage.

To work around this issue, detect the combination of linear RT, early
test and late write and switch to late test in that case.

Fixes: 53445284a427 ("etnaviv: add linear PE support")
Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17215>

---

 src/gallium/drivers/etnaviv/etnaviv_state.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c
index 66aaabd289f..1f9883ce748 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_state.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_state.c
@@ -738,6 +738,20 @@ etna_update_zsa(struct etna_context *ctx)
          late_z_test = true;
    }
 
+   /* Linear PE breaks the combination of early test with late write, as it
+    * seems RA and PE disagree about the cache layout in this mode. Switch to
+    * late test to work around this issue.
+    */
+   if (ctx->framebuffer_s.nr_cbufs > 0) {
+      struct etna_surface *cbuf = etna_surface(ctx->framebuffer_s.cbufs[0]);
+      struct etna_resource *res = etna_resource(cbuf->base.texture);
+
+      if (res->layout == ETNA_LAYOUT_LINEAR && early_z_test && late_z_write) {
+         early_z_test = false;
+         late_z_test = true;
+      }
+   }
+
    new_pe_depth = VIVS_PE_DEPTH_CONFIG_DEPTH_FUNC(zsa->z_test_enabled ?
                      /* compare funcs have 1 to 1 mapping */
                      zsa_state->depth_func : PIPE_FUNC_ALWAYS) |
@@ -812,7 +826,8 @@ static const struct etna_state_updater etna_state_updates[] = {
                             ETNA_DIRTY_RASTERIZER | ETNA_DIRTY_VIEWPORT,
    },
    {
-      etna_update_zsa, ETNA_DIRTY_ZSA | ETNA_DIRTY_SHADER,
+      etna_update_zsa, ETNA_DIRTY_ZSA | ETNA_DIRTY_SHADER |
+                       ETNA_DIRTY_FRAMEBUFFER,
    },
    {
       etna_record_flush_resources, ETNA_DIRTY_FRAMEBUFFER,



More information about the mesa-commit mailing list