Mesa (main): freedreno: Flush batches upon destroying the ctx.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 17 16:32:13 UTC 2021


Module: Mesa
Branch: main
Commit: ac9ae97d304c5050262285db6d2fe4897a932653
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac9ae97d304c5050262285db6d2fe4897a932653

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Jun 15 13:58:50 2021 -0700

freedreno: Flush batches upon destroying the ctx.

The invalidate would take it out of the bc tracking, so you could go
allocate a new batch->idx matching this one, while this one is still in
the bc using that idx.

You can't generate any new rendering with the ctx's old batches at this
point, anyway, so just flush for simplicity.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11439>

---

 src/gallium/drivers/freedreno/freedreno_batch_cache.c | 16 ----------------
 src/gallium/drivers/freedreno/freedreno_batch_cache.h |  1 -
 src/gallium/drivers/freedreno/freedreno_context.c     |  4 +++-
 3 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
index 278d5871be5..5b514e90973 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
@@ -222,22 +222,6 @@ fd_bc_dump(struct fd_context *ctx, const char *fmt, ...)
    fd_screen_unlock(ctx->screen);
 }
 
-void
-fd_bc_invalidate_context(struct fd_context *ctx)
-{
-   struct fd_batch_cache *cache = &ctx->screen->batch_cache;
-   struct fd_batch *batch;
-
-   fd_screen_lock(ctx->screen);
-
-   foreach_batch (batch, cache, cache->batch_mask) {
-      if (batch->ctx == ctx)
-         fd_bc_invalidate_batch(batch, true);
-   }
-
-   fd_screen_unlock(ctx->screen);
-}
-
 /**
  * Note that when batch is flushed, it needs to remain in the cache so
  * that fd_bc_invalidate_resource() can work.. otherwise we can have
diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.h b/src/gallium/drivers/freedreno/freedreno_batch_cache.h
index c85a6976583..d9d6c2c307e 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.h
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.h
@@ -70,7 +70,6 @@ void fd_bc_flush(struct fd_context *ctx, bool deferred) assert_dt;
 void fd_bc_dump(struct fd_context *ctx, const char *fmt, ...)
    _util_printf_format(2, 3);
 
-void fd_bc_invalidate_context(struct fd_context *ctx);
 void fd_bc_invalidate_batch(struct fd_batch *batch, bool destroy);
 void fd_bc_invalidate_resource(struct fd_resource *rsc, bool destroy);
 struct fd_batch *fd_bc_alloc_batch(struct fd_context *ctx,
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
index 618df948732..374a95a4845 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -350,7 +350,9 @@ fd_context_destroy(struct pipe_context *pctx)
 
    util_copy_framebuffer_state(&ctx->framebuffer, NULL);
    fd_batch_reference(&ctx->batch, NULL); /* unref current batch */
-   fd_bc_invalidate_context(ctx);
+
+   /* Make sure nothing in the batch cache references our context any more. */
+   fd_bc_flush(ctx, false);
 
    fd_prog_fini(pctx);
 



More information about the mesa-commit mailing list