freedreno/a6xx: Move restore blits to IB
authorKristian H. Kristensen <hoegsberg@chromium.org>
Wed, 24 Oct 2018 06:50:34 +0000 (23:50 -0700)
committerRob Clark <robdclark@gmail.com>
Tue, 27 Nov 2018 20:44:02 +0000 (15:44 -0500)
Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a6xx/fd6_gmem.c
src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_batch.h

index 75bbcc7bac4776b637cb6244e799f51e4c068241..6755f2ab6b4b630d9f1c4b3f40a2d55c9c110dda 100644 (file)
@@ -449,6 +449,8 @@ disable_msaa(struct fd_ringbuffer *ring)
                         A6XX_RB_DEST_MSAA_CNTL_MSAA_DISABLE);
 }
 
+static void prepare_tile_setup_ib(struct fd_batch *batch);
+
 /* before first tile */
 static void
 fd6_emit_tile_init(struct fd_batch *batch)
@@ -467,6 +469,8 @@ fd6_emit_tile_init(struct fd_batch *batch)
 
        fd6_cache_flush(batch, ring);
 
+       prepare_tile_setup_ib(batch);
+
        OUT_PKT7(ring, CP_SKIP_IB2_ENABLE_GLOBAL, 1);
        OUT_RING(ring, 0x0);
 
@@ -580,9 +584,8 @@ fd6_emit_tile_prep(struct fd_batch *batch, struct fd_tile *tile)
 }
 
 static void
-set_blit_scissor(struct fd_batch *batch)
+set_blit_scissor(struct fd_batch *batch, struct fd_ringbuffer *ring)
 {
-       struct fd_ringbuffer *ring = batch->gmem;
        struct pipe_scissor_state blit_scissor;
        struct pipe_framebuffer_state *pfb = &batch->framebuffer;
 
@@ -601,11 +604,12 @@ set_blit_scissor(struct fd_batch *batch)
 }
 
 static void
-emit_blit(struct fd_batch *batch, uint32_t base,
+emit_blit(struct fd_batch *batch,
+                 struct fd_ringbuffer *ring,
+                 uint32_t base,
                  struct pipe_surface *psurf,
                  struct fd_resource *rsc)
 {
-       struct fd_ringbuffer *ring = batch->gmem;
        struct fd_resource_slice *slice;
        uint32_t offset;
 
@@ -642,12 +646,13 @@ emit_blit(struct fd_batch *batch, uint32_t base,
 }
 
 static void
-emit_restore_blit(struct fd_batch *batch, uint32_t base,
+emit_restore_blit(struct fd_batch *batch,
+                                 struct fd_ringbuffer *ring,
+                                 uint32_t base,
                                  struct pipe_surface *psurf,
                                  struct fd_resource *rsc,
                                  unsigned buffer)
 {
-       struct fd_ringbuffer *ring = batch->gmem;
        uint32_t info = 0;
 
        switch (buffer) {
@@ -668,52 +673,70 @@ emit_restore_blit(struct fd_batch *batch, uint32_t base,
        OUT_PKT4(ring, REG_A6XX_RB_BLIT_INFO, 1);
        OUT_RING(ring, info | A6XX_RB_BLIT_INFO_GMEM);
 
-       emit_blit(batch, base, psurf, rsc);
+       emit_blit(batch, ring, base, psurf, rsc);
 }
 
 /*
  * transfer from system memory to gmem
  */
 static void
-fd6_emit_tile_mem2gmem(struct fd_batch *batch, struct fd_tile *tile)
+emit_restore_blits(struct fd_batch *batch, struct fd_ringbuffer *ring)
 {
        struct fd_context *ctx = batch->ctx;
        struct fd_gmem_stateobj *gmem = &ctx->gmem;
        struct pipe_framebuffer_state *pfb = &batch->framebuffer;
 
-       set_blit_scissor(batch);
-
-       if (fd_gmem_needs_restore(batch, tile, FD_BUFFER_COLOR)) {
+       if (batch->restore & FD_BUFFER_COLOR) {
                unsigned i;
                for (i = 0; i < pfb->nr_cbufs; i++) {
                        if (!pfb->cbufs[i])
                                continue;
                        if (!(batch->restore & (PIPE_CLEAR_COLOR0 << i)))
                                continue;
-                       emit_restore_blit(batch, gmem->cbuf_base[i], pfb->cbufs[i],
+                       emit_restore_blit(batch, ring, gmem->cbuf_base[i], pfb->cbufs[i],
                                                          fd_resource(pfb->cbufs[i]->texture),
                                                          FD_BUFFER_COLOR);
                }
        }
 
-       if (fd_gmem_needs_restore(batch, tile, FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
+       if (batch->restore & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
                struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
 
-               if (!rsc->stencil || fd_gmem_needs_restore(batch, tile, FD_BUFFER_DEPTH)) {
-                       emit_restore_blit(batch, gmem->zsbuf_base[0], pfb->zsbuf, rsc,
+               if (!rsc->stencil || (batch->restore & FD_BUFFER_DEPTH)) {
+                       emit_restore_blit(batch, ring, gmem->zsbuf_base[0], pfb->zsbuf, rsc,
                                                          FD_BUFFER_DEPTH);
                }
-               if (rsc->stencil && fd_gmem_needs_restore(batch, tile, FD_BUFFER_STENCIL)) {
-                       emit_restore_blit(batch, gmem->zsbuf_base[1], pfb->zsbuf, rsc->stencil,
+               if (rsc->stencil && (batch->restore & FD_BUFFER_STENCIL)) {
+                       emit_restore_blit(batch, ring, gmem->zsbuf_base[1], pfb->zsbuf, rsc->stencil,
                                                          FD_BUFFER_STENCIL);
                }
        }
 }
 
+static void
+prepare_tile_setup_ib(struct fd_batch *batch)
+{
+       batch->tile_setup = fd_submit_new_ringbuffer(batch->submit, 0x1000,
+                       FD_RINGBUFFER_STREAMING);
+
+       set_blit_scissor(batch, batch->tile_setup);
+
+       emit_restore_blits(batch, batch->tile_setup);
+}
+
+/*
+ * transfer from system memory to gmem
+ */
+static void
+fd6_emit_tile_mem2gmem(struct fd_batch *batch, struct fd_tile *tile)
+{
+}
+
 /* before IB to rendering cmds: */
 static void
 fd6_emit_tile_renderprep(struct fd_batch *batch, struct fd_tile *tile)
 {
+       fd6_emit_ib(batch->gmem, batch->tile_setup);
 }
 
 static void
@@ -745,7 +768,7 @@ emit_resolve_blit(struct fd_batch *batch, uint32_t base,
        OUT_PKT4(ring, REG_A6XX_RB_BLIT_INFO, 1);
        OUT_RING(ring, info);
 
-       emit_blit(batch, base, psurf, rsc);
+       emit_blit(batch, batch->gmem, base, psurf, rsc);
 }
 
 /*
@@ -780,7 +803,7 @@ fd6_emit_tile_gmem2mem(struct fd_batch *batch, struct fd_tile *tile)
        OUT_RING(ring, A2XX_CP_SET_MARKER_0_MODE(RM6_RESOLVE) | 0x10);
        emit_marker6(ring, 7);
 
-       set_blit_scissor(batch);
+       set_blit_scissor(batch, ring);
 
        if (batch->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
                struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
index 2c5673f34409203c00bcdc39e2227bec530f8cfb..9a35f145d19b94722de1311e9d8fc58efd6ee492 100644 (file)
@@ -144,11 +144,17 @@ batch_fini(struct fd_batch *batch)
                debug_assert(!batch->binning);
                debug_assert(!batch->gmem);
        }
+
        if (batch->lrz_clear) {
                fd_ringbuffer_del(batch->lrz_clear);
                batch->lrz_clear = NULL;
        }
 
+       if (batch->tile_setup) {
+               fd_ringbuffer_del(batch->tile_setup);
+               batch->tile_setup = NULL;
+       }
+
        fd_submit_del(batch->submit);
 
        util_dynarray_fini(&batch->draw_patches);
index e0902f669148bd923c0a80996b0467f5c30db85a..0ba6da5edc3fd127ad63d823e60173295d84ef2d 100644 (file)
@@ -162,6 +162,7 @@ struct fd_batch {
 
        // TODO maybe more generically split out clear and clear_binning rings?
        struct fd_ringbuffer *lrz_clear;
+       struct fd_ringbuffer *tile_setup;
 
        /**
         * hw query related state: