freedreno: small fix for flushing dependent batches
authorRob Clark <robdclark@gmail.com>
Sat, 10 Feb 2018 19:12:11 +0000 (14:12 -0500)
committerRob Clark <robdclark@gmail.com>
Sat, 10 Feb 2018 19:54:58 +0000 (14:54 -0500)
Flush a resource's previous write_batch synchronously.  Because a
resource's associated batches are not updated until after the flush
thread submits rendering to the kernel, this was causing a bit of
confusion in the following loop.  This fixes a bug that appeared with
recent stk.

Perhaps we need to re-work things a bit to clear out dependent patches
in the ctx's thread and use a fence to deal with the period between
when a flush is queued and when it is submitted to the kernel.  But
this will do until time permits a larger refactor.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_batch.c

index e44e8e5403e45ef8ec143c4768381781deb44848..9918c259e48e9dac69ae8b36d012d1f9be679241 100644 (file)
@@ -405,6 +405,19 @@ fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc, bool wri
                if (rsc->batch_mask != (1 << batch->idx)) {
                        struct fd_batch_cache *cache = &batch->ctx->screen->batch_cache;
                        struct fd_batch *dep;
+
+                       if (rsc->write_batch && rsc->write_batch != batch) {
+                               struct fd_batch *b = NULL;
+                               fd_batch_reference(&b, rsc->write_batch);
+
+                               mtx_unlock(&batch->ctx->screen->lock);
+                               fd_batch_flush(b, true, false);
+                               mtx_lock(&batch->ctx->screen->lock);
+
+                               fd_bc_invalidate_batch(b, false);
+                               fd_batch_reference_locked(&b, NULL);
+                       }
+
                        foreach_batch(dep, cache, rsc->batch_mask) {
                                struct fd_batch *b = NULL;
                                if (dep == batch)