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>
This commit is contained in:
Emma Anholt 2021-06-15 13:58:50 -07:00
parent 2a9225d05f
commit ac9ae97d30
3 changed files with 3 additions and 18 deletions

View file

@ -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

View file

@ -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,

View file

@ -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);