tu: Remove useless post-binning flushes
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 9 Jun 2020 13:25:40 +0000 (15:25 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 9 Jun 2020 14:40:51 +0000 (14:40 +0000)
The Vulkan blob doesn't do this, and based on my understanding of how
the blob works this is unnecessary. CACHE_FLUSH is already serialized
against all 3d commands so you don't need to wait for rendering commands
to finish before issuing it, and the subsequent wfi + WAIT_FOR_ME will
cause the CP to wait for the CACHE_FLUSH to finish, so there's also no
need to wait for it to complete. The CACHE_INVALIDATE also seems
unnecessary, and also isn't done by the blob.

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

src/freedreno/vulkan/tu_cmd_buffer.c

index a1f690288d7127e3750b4c2e26dda62b62046ae6..2ba4964fa310caa86e393d4c9c687452e3600775 100644 (file)
@@ -883,29 +883,6 @@ tu6_init_hw(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
    tu_cs_sanity_check(cs);
 }
 
-static void
-tu6_cache_flush(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
-{
-   unsigned seqno;
-
-   seqno = tu6_emit_event_write(cmd, cs, RB_DONE_TS, true);
-
-   tu_cs_emit_pkt7(cs, CP_WAIT_REG_MEM, 6);
-   tu_cs_emit(cs, CP_WAIT_REG_MEM_0_FUNCTION(WRITE_EQ) |
-                  CP_WAIT_REG_MEM_0_POLL_MEMORY);
-   tu_cs_emit_qw(cs, cmd->scratch_bo.iova);
-   tu_cs_emit(cs, CP_WAIT_REG_MEM_3_REF(seqno));
-   tu_cs_emit(cs, CP_WAIT_REG_MEM_4_MASK(~0));
-   tu_cs_emit(cs, CP_WAIT_REG_MEM_5_DELAY_LOOP_CYCLES(16));
-
-   seqno = tu6_emit_event_write(cmd, cs, CACHE_FLUSH_TS, true);
-
-   tu_cs_emit_pkt7(cs, CP_WAIT_MEM_GTE, 4);
-   tu_cs_emit(cs, CP_WAIT_MEM_GTE_0_RESERVED(0));
-   tu_cs_emit_qw(cs, cmd->scratch_bo.iova);
-   tu_cs_emit(cs, CP_WAIT_MEM_GTE_3_REF(seqno));
-}
-
 static void
 update_vsc_pipe(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
 {
@@ -1079,8 +1056,15 @@ tu6_emit_binning_pass(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
    tu_cs_emit_pkt7(cs, CP_EVENT_WRITE, 1);
    tu_cs_emit(cs, UNK_2D);
 
-   tu6_emit_event_write(cmd, cs, CACHE_INVALIDATE, false);
-   tu6_cache_flush(cmd, cs);
+   /* This flush is probably required because the VSC, which produces the
+    * visibility stream, is a client of UCHE, whereas the CP needs to read the
+    * visibility stream (without caching) to do draw skipping. The
+    * WFI+WAIT_FOR_ME combination guarantees that the binning commands
+    * submitted are finished before reading the VSC regs (in
+    * emit_vsc_overflow_test) or the VSC_DATA buffer directly (implicitly as
+    * part of draws).
+    */
+   tu6_emit_event_write(cmd, cs, CACHE_FLUSH_TS, true);
 
    tu_cs_emit_wfi(cs);