freedreno/a6xx: Move resolve blits to an IB
[mesa.git] / src / gallium / drivers / freedreno / freedreno_batch.c
index 340756e059abc38f17a4e043785e703b3419f6cc..de4c8198c201478dfaba4fc362a994714ff77479 100644 (file)
@@ -48,28 +48,35 @@ batch_init(struct fd_batch *batch)
         * have no option but to allocate large worst-case sizes so that
         * we don't need to grow the ringbuffer.  Performance is likely to
         * suffer, but there is no good alternative.
+        *
+        * XXX I think we can just require new enough kernel for this?
         */
        if ((fd_device_version(ctx->screen->dev) < FD_VERSION_UNLIMITED_CMDS) ||
                        (fd_mesa_debug & FD_DBG_NOGROW)){
                size = 0x100000;
        }
 
-       batch->draw    = fd_ringbuffer_new(ctx->pipe, size);
-       if (!batch->nondraw) {
-               batch->binning = fd_ringbuffer_new(ctx->pipe, size);
-               batch->gmem    = fd_ringbuffer_new(ctx->pipe, size);
-
-               fd_ringbuffer_set_parent(batch->gmem, NULL);
-               fd_ringbuffer_set_parent(batch->draw, batch->gmem);
-               fd_ringbuffer_set_parent(batch->binning, batch->gmem);
+       batch->submit = fd_submit_new(ctx->pipe);
+       if (batch->nondraw) {
+               batch->draw = fd_submit_new_ringbuffer(batch->submit, size,
+                               FD_RINGBUFFER_PRIMARY | FD_RINGBUFFER_GROWABLE);
        } else {
-               fd_ringbuffer_set_parent(batch->draw, NULL);
+               batch->gmem = fd_submit_new_ringbuffer(batch->submit, size,
+                               FD_RINGBUFFER_PRIMARY | FD_RINGBUFFER_GROWABLE);
+               batch->draw = fd_submit_new_ringbuffer(batch->submit, size,
+                               FD_RINGBUFFER_GROWABLE);
+
+               if (ctx->screen->gpu_id < 600) {
+                       batch->binning = fd_submit_new_ringbuffer(batch->submit,
+                                       size, FD_RINGBUFFER_GROWABLE);
+               }
        }
 
        batch->in_fence_fd = -1;
        batch->fence = fd_fence_create(batch);
 
        batch->cleared = 0;
+       batch->invalidated = 0;
        batch->restore = batch->resolve = 0;
        batch->needs_flush = false;
        batch->flushed = false;
@@ -130,17 +137,31 @@ batch_fini(struct fd_batch *batch)
 
        fd_ringbuffer_del(batch->draw);
        if (!batch->nondraw) {
-               fd_ringbuffer_del(batch->binning);
+               if (batch->binning)
+                       fd_ringbuffer_del(batch->binning);
                fd_ringbuffer_del(batch->gmem);
        } else {
                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;
+       }
+
+       if (batch->tile_fini) {
+               fd_ringbuffer_del(batch->tile_fini);
+               batch->tile_fini = NULL;
+       }
+
+       fd_submit_del(batch->submit);
+
        util_dynarray_fini(&batch->draw_patches);
 
        if (is_a3xx(batch->ctx->screen))
@@ -177,8 +198,6 @@ batch_flush_reset_dependencies(struct fd_batch *batch, bool flush)
 static void
 batch_reset_resources_locked(struct fd_batch *batch)
 {
-       struct set_entry *entry;
-
        pipe_mutex_assert_locked(batch->ctx->screen->lock);
 
        set_foreach(batch->resources, entry) {
@@ -355,12 +374,13 @@ fd_batch_flush(struct fd_batch *batch, bool sync, bool force)
                         */
                        new_batch = NULL;
                } else {
-                       new_batch = fd_batch_create(ctx, false);
+                       new_batch = fd_bc_alloc_batch(&ctx->screen->batch_cache, ctx, false);
                        util_copy_framebuffer_state(&new_batch->framebuffer, &batch->framebuffer);
                }
 
                fd_batch_reference(&batch, NULL);
                ctx->batch = new_batch;
+               fd_context_all_dirty(ctx);
        }
 
        if (sync)
@@ -465,8 +485,10 @@ fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc, bool wri
                        flush_write_batch(rsc);
        }
 
-       if (rsc->batch_mask & (1 << batch->idx))
+       if (rsc->batch_mask & (1 << batch->idx)) {
+               debug_assert(_mesa_set_search(batch->resources, rsc));
                return;
+       }
 
        debug_assert(!_mesa_set_search(batch->resources, rsc));