freedreno/batch: replace lrz_clear with prologue
authorRob Clark <robdclark@chromium.org>
Wed, 26 Aug 2020 17:44:44 +0000 (10:44 -0700)
committerMarge Bot <eric+marge@anholt.net>
Fri, 28 Aug 2020 22:24:25 +0000 (22:24 +0000)
Replace lrz_clear with the more general purpose prologue rb.  While the
epilogue is per-tile (in gmem mode), the prologue is per-batch, so also
add some comments to make that point more clear.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6475>

src/gallium/drivers/freedreno/a5xx/fd5_draw.c
src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
src/gallium/drivers/freedreno/a6xx/fd6_draw.c
src/gallium/drivers/freedreno/a6xx/fd6_gmem.c
src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_batch.h

index 05fdaf78b51087d4434ab945bf84444572302f11..0d7514de6e8d1a012c75dd5db5dbebd2e0e19b79 100644 (file)
@@ -190,17 +190,7 @@ fd5_clear_lrz(struct fd_batch *batch, struct fd_resource *zsbuf, double depth)
        struct fd_ringbuffer *ring;
        uint32_t clear = util_pack_z(PIPE_FORMAT_Z16_UNORM, depth);
 
-       // TODO mid-frame clears (ie. app doing crazy stuff)??  Maybe worth
-       // splitting both clear and lrz clear out into their own rb's.  And
-       // just throw away any draws prior to clear.  (Anything not fullscreen
-       // clear, just fallback to generic path that treats it as a normal
-       // draw
-
-       if (!batch->lrz_clear) {
-               batch->lrz_clear = fd_submit_new_ringbuffer(batch->submit, 0x1000, 0);
-       }
-
-       ring = batch->lrz_clear;
+       ring = fd_batch_get_prologue(batch);
 
        OUT_WFI5(ring);
 
index 61bc443c724f85b0574f5560757f011e9906ec1b..b574bcd880d2ede53ef439584d5510862f37e5ee 100644 (file)
@@ -369,8 +369,8 @@ fd5_emit_tile_init(struct fd_batch *batch)
 
        fd5_emit_restore(batch, ring);
 
-       if (batch->lrz_clear)
-               fd5_emit_ib(ring, batch->lrz_clear);
+       if (batch->prologue)
+               fd5_emit_ib(ring, batch->prologue);
 
        fd5_emit_lrz_flush(ring);
 
@@ -700,6 +700,9 @@ fd5_emit_sysmem_prep(struct fd_batch *batch)
 
        fd5_emit_lrz_flush(ring);
 
+       if (batch->prologue)
+               fd5_emit_ib(ring, batch->prologue);
+
        OUT_PKT7(ring, CP_SKIP_IB2_ENABLE_GLOBAL, 1);
        OUT_RING(ring, 0x0);
 
index e95c400dd387e69047200f1544cc118a1fbd5643..3e9ec98d5fca5d486e79c26a68b812be7c68f464 100644 (file)
@@ -345,12 +345,7 @@ fd6_clear_lrz(struct fd_batch *batch, struct fd_resource *zsbuf, double depth)
        struct fd_ringbuffer *ring;
        struct fd6_context *fd6_ctx = fd6_context(batch->ctx);
 
-       if (batch->lrz_clear) {
-               fd_ringbuffer_del(batch->lrz_clear);
-       }
-
-       batch->lrz_clear = fd_submit_new_ringbuffer(batch->submit, 0x1000, 0);
-       ring = batch->lrz_clear;
+       ring = fd_batch_get_prologue(batch);
 
        emit_marker6(ring, 7);
        OUT_PKT7(ring, CP_SET_MARKER, 1);
index eb4cbbf52df5d80cdf10d2818df8a1f53dff247f..32ea772a5bc3a407241dd76a59f3b2c3ba34e40a 100644 (file)
@@ -677,10 +677,10 @@ fd6_emit_tile_init(struct fd_batch *batch)
 
        fd6_emit_lrz_flush(ring);
 
-       if (batch->lrz_clear) {
-               fd_log(batch, "START LRZ CLEAR");
-               fd6_emit_ib(ring, batch->lrz_clear);
-               fd_log(batch, "END LRZ CLEAR");
+       if (batch->prologue) {
+               fd_log(batch, "START PROLOGUE");
+               fd6_emit_ib(ring, batch->prologue);
+               fd_log(batch, "END PROLOGUE");
        }
 
        fd6_cache_inv(batch, ring);
@@ -1364,6 +1364,13 @@ fd6_emit_sysmem_prep(struct fd_batch *batch)
        struct fd_ringbuffer *ring = batch->gmem;
 
        fd6_emit_restore(batch, ring);
+       fd6_emit_lrz_flush(ring);
+
+       if (batch->prologue) {
+               fd_log(batch, "START PROLOGUE");
+               fd6_emit_ib(ring, batch->prologue);
+               fd_log(batch, "END PROLOGUE");
+       }
 
        if (pfb->width > 0 && pfb->height > 0)
                set_scissor(ring, 0, 0, pfb->width - 1, pfb->height - 1);
@@ -1376,11 +1383,6 @@ fd6_emit_sysmem_prep(struct fd_batch *batch)
 
        emit_sysmem_clears(batch, ring);
 
-       fd6_emit_lrz_flush(ring);
-
-       if (batch->lrz_clear)
-               fd6_emit_ib(ring, batch->lrz_clear);
-
        emit_marker6(ring, 7);
        OUT_PKT7(ring, CP_SET_MARKER, 1);
        OUT_RING(ring, A6XX_CP_SET_MARKER_0_MODE(RM6_BYPASS));
index 86e8b5b7834e038a6ceead8193a670fd8a03e051..1a93a8272c9ba48f53dc63b428af343ceb2d6bdb 100644 (file)
@@ -164,9 +164,9 @@ batch_fini(struct fd_batch *batch)
                debug_assert(!batch->gmem);
        }
 
-       if (batch->lrz_clear) {
-               fd_ringbuffer_del(batch->lrz_clear);
-               batch->lrz_clear = NULL;
+       if (batch->prologue) {
+               fd_ringbuffer_del(batch->prologue);
+               batch->prologue = NULL;
        }
 
        if (batch->epilogue) {
@@ -336,6 +336,15 @@ batch_flush(struct fd_batch *batch)
        fd_screen_unlock(batch->ctx->screen);
 }
 
+/* Get per-batch prologue */
+struct fd_ringbuffer *
+fd_batch_get_prologue(struct fd_batch *batch)
+{
+       if (!batch->prologue)
+               batch->prologue = alloc_ring(batch, 0x1000, 0);
+       return batch->prologue;
+}
+
 /* NOTE: could drop the last ref to batch
  *
  * @sync: synchronize with flush_queue, ensures batch is *actually* flushed
index b7b970359a357d13040c199e2b1584042f1f3832..1e33654b04db9875d7f0184966d320c7d16280d7 100644 (file)
@@ -190,11 +190,12 @@ struct fd_batch {
        /** tiling/gmem (IB0) cmdstream: */
        struct fd_ringbuffer *gmem;
 
-       /** epilogue cmdstream: */
+       /** preemble cmdstream (executed once before first tile): */
+       struct fd_ringbuffer *prologue;
+
+       /** epilogue cmdstream (executed after each tile): */
        struct fd_ringbuffer *epilogue;
 
-       // TODO maybe more generically split out clear and clear_binning rings?
-       struct fd_ringbuffer *lrz_clear;
        struct fd_ringbuffer *tile_setup;
        struct fd_ringbuffer *tile_fini;
 
@@ -345,6 +346,7 @@ fd_event_write(struct fd_batch *batch, struct fd_ringbuffer *ring,
        fd_reset_wfi(batch);
 }
 
+/* Get per-tile epilogue */
 static inline struct fd_ringbuffer *
 fd_batch_get_epilogue(struct fd_batch *batch)
 {
@@ -354,5 +356,6 @@ fd_batch_get_epilogue(struct fd_batch *batch)
        return batch->epilogue;
 }
 
+struct fd_ringbuffer * fd_batch_get_prologue(struct fd_batch *batch);
 
 #endif /* FREEDRENO_BATCH_H_ */