freedreno: deferred flush support
authorRob Clark <robdclark@gmail.com>
Sun, 19 Nov 2017 16:42:25 +0000 (11:42 -0500)
committerRob Clark <robdclark@gmail.com>
Sun, 3 Dec 2017 19:17:41 +0000 (14:17 -0500)
Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_batch.h
src/gallium/drivers/freedreno/freedreno_batch_cache.c
src/gallium/drivers/freedreno/freedreno_batch_cache.h
src/gallium/drivers/freedreno/freedreno_context.c

index 2b7e19a6333b6117c28686120c099b54bad3f873..eff5e8dc359530ad045f1a17f3398a910255a027 100644 (file)
@@ -350,8 +350,8 @@ batch_depends_on(struct fd_batch *batch, struct fd_batch *other)
        return false;
 }
 
-static void
-batch_add_dep(struct fd_batch *batch, struct fd_batch *dep)
+void
+fd_batch_add_dep(struct fd_batch *batch, struct fd_batch *dep)
 {
        if (batch->dependents_mask & (1 << dep->idx))
                return;
@@ -398,7 +398,7 @@ fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc, bool wri
                                 * fd_bc_invalidate_batch()
                                 */
                                fd_batch_reference(&b, dep);
-                               batch_add_dep(batch, b);
+                               fd_batch_add_dep(batch, b);
                                fd_bc_invalidate_batch(b, false);
                                fd_batch_reference_locked(&b, NULL);
                        }
@@ -406,7 +406,7 @@ fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc, bool wri
                fd_batch_reference_locked(&rsc->write_batch, batch);
        } else {
                if (rsc->write_batch) {
-                       batch_add_dep(batch, rsc->write_batch);
+                       fd_batch_add_dep(batch, rsc->write_batch);
                        fd_bc_invalidate_batch(rsc->write_batch, false);
                }
        }
index a5fa6ce5a22d1027a658b602e1fef154b2c08bdb..d69ff6f80b683c197a108b396a933b7f5403076a 100644 (file)
@@ -207,6 +207,7 @@ struct fd_batch * fd_batch_create(struct fd_context *ctx);
 void fd_batch_reset(struct fd_batch *batch);
 void fd_batch_sync(struct fd_batch *batch);
 void fd_batch_flush(struct fd_batch *batch, bool sync, bool force);
+void fd_batch_add_dep(struct fd_batch *batch, struct fd_batch *dep);
 void fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc, bool write);
 void fd_batch_check_size(struct fd_batch *batch);
 
index 470aca4f38090d112354ad8a421839bcd540c4a0..def13285138c31f354a65340478c6b0b71b8c859 100644 (file)
@@ -153,6 +153,30 @@ fd_bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx)
        }
 }
 
+/* deferred flush doesn't actually flush, but it marks every other
+ * batch associated with the context as dependent on the current
+ * batch.  So when the current batch gets flushed, all other batches
+ * that came before also get flushed.
+ */
+void
+fd_bc_flush_deferred(struct fd_batch_cache *cache, struct fd_context *ctx)
+{
+       struct fd_batch *current_batch = ctx->batch;
+       struct hash_entry *entry;
+
+       mtx_lock(&ctx->screen->lock);
+
+       hash_table_foreach(cache->ht, entry) {
+               struct fd_batch *batch = entry->data;
+               if (batch == current_batch)
+                       continue;
+               if (batch->ctx == ctx)
+                       fd_batch_add_dep(current_batch, batch);
+       }
+
+       mtx_unlock(&ctx->screen->lock);
+}
+
 void
 fd_bc_invalidate_context(struct fd_context *ctx)
 {
index 44c66b58f3b5037412720fa20a49ae15ee47ed22..348418e18769233034c573b2126b63ac4993554a 100644 (file)
@@ -63,6 +63,7 @@ void fd_bc_init(struct fd_batch_cache *cache);
 void fd_bc_fini(struct fd_batch_cache *cache);
 
 void fd_bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx);
+void fd_bc_flush_deferred(struct fd_batch_cache *cache, struct fd_context *ctx);
 
 void fd_bc_invalidate_context(struct fd_context *ctx);
 void fd_bc_invalidate_batch(struct fd_batch *batch, bool destroy);
index e138ac94ae3cd4ae492d1288e6841d8ef5498bd6..0ec81f882daf7341ceb88097a5323075225f3246 100644 (file)
@@ -54,6 +54,8 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
 
        if (!ctx->screen->reorder) {
                fd_batch_flush(ctx->batch, true, false);
+       } else if (flags & PIPE_FLUSH_DEFERRED) {
+               fd_bc_flush_deferred(&ctx->screen->batch_cache, ctx);
        } else {
                fd_bc_flush(&ctx->screen->batch_cache, ctx);
        }