From ac9ae97d304c5050262285db6d2fe4897a932653 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 15 Jun 2021 13:58:50 -0700 Subject: [PATCH] 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: --- 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 278d587..5b514e9 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 c85a697..d9d6c2c 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 618df94..374a95a 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); -- 2.7.4