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

Author: Emma Anholt <[email protected]>
Date:   Tue Sep 13 16:16:30 2022 -0700

turnip: Skip rather than invalidate LRZ on gl_FragDepth writes.

As long as the direction is still compatible, if we skip the LRZ use and
updates for this draw, then we can keep using LRZ later in the scene, as
whatever gl_FragDepth will get written by the shader later will still have
to move the depth in the right direction.

Similarly, the no_earlyz flag that contributes to DISABLE_LRZ just wants
to make sure we don't kill fragments before dispatch, not change what Z
eventually lands.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18606>

---

 src/freedreno/vulkan/tu_lrz.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/freedreno/vulkan/tu_lrz.c b/src/freedreno/vulkan/tu_lrz.c
index be487a4377f..514c428bc95 100644
--- a/src/freedreno/vulkan/tu_lrz.c
+++ b/src/freedreno/vulkan/tu_lrz.c
@@ -702,12 +702,18 @@ tu6_calculate_lrz_state(struct tu_cmd_buffer *cmd,
    bool disable_lrz = false;
    bool temporary_disable_lrz = false;
 
-   /* What happens in FS could affect LRZ, e.g.: writes to gl_FragDepth
-    * or early fragment tests.
+   /* What happens in FS could affect LRZ, e.g.: writes to gl_FragDepth or 
early
+    * fragment tests.  We have to skip LRZ testing and updating, but as long as
+    * the depth direction stayed the same we can continue with LRZ testing 
later.
     */
    if (pipeline->lrz.force_disable_mask & TU_LRZ_FORCE_DISABLE_LRZ) {
-      perf_debug(cmd->device, "Invalidating LRZ due to FS");
-      disable_lrz = true;
+      if (cmd->state.lrz.prev_direction != TU_LRZ_UNKNOWN || 
!cmd->state.lrz.gpu_dir_tracking) {
+         perf_debug(cmd->device, "Skipping LRZ due to FS");
+         temporary_disable_lrz = true;
+      } else {
+         perf_debug(cmd->device, "Disabling LRZ due to FS (TODO: fix for 
gpu-direction-tracking case");
+         disable_lrz = true;
+      }
    }
 
    /* If Z is not written - it doesn't affect LRZ buffer state.

Reply via email to