freedreno: allow ctx->batch to be NULL

This was mostly true already, now that we use `fd_context_batch()` for
first access to batch in draw/clear/grid paths.  So we can drop the old
code in `batch_flush()` that tried to prevent `ctx->batch` from being
NULL.

Fixes a crash with a large number of tabs in chromium.

Cc: "20.0" mesa-stable@lists.freedesktop.org
Signed-off-by: Rob Clark <robdclark@chromium.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3700>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3700>
This commit is contained in:
Rob Clark
2020-02-04 13:46:56 -08:00
committed by Marge Bot
parent 22d2cbe685
commit 2c07e03b79
4 changed files with 2 additions and 30 deletions

View File

@@ -321,7 +321,6 @@ void
fd_batch_flush(struct fd_batch *batch)
{
struct fd_batch *tmp = NULL;
bool newbatch = false;
/* NOTE: we need to hold an extra ref across the body of flush,
* since the last ref to this batch could be dropped when cleaning
@@ -329,30 +328,10 @@ fd_batch_flush(struct fd_batch *batch)
*/
fd_batch_reference(&tmp, batch);
if (batch == batch->ctx->batch) {
batch->ctx->batch = NULL;
newbatch = true;
}
batch_flush(tmp);
if (newbatch) {
struct fd_context *ctx = batch->ctx;
struct fd_batch *new_batch;
if (ctx->screen->reorder) {
/* defer allocating new batch until one is needed for rendering
* to avoid unused batches for apps that create many contexts
*/
new_batch = NULL;
} else {
new_batch = fd_bc_alloc_batch(&ctx->screen->batch_cache, ctx, false);
util_copy_framebuffer_state(&new_batch->framebuffer, &batch->framebuffer);
}
fd_batch_reference(&batch, NULL);
ctx->batch = new_batch;
fd_context_all_dirty(ctx);
if (batch == batch->ctx->batch) {
fd_batch_reference(&batch->ctx->batch, NULL);
}
fd_batch_reference(&tmp, NULL);

View File

@@ -295,9 +295,6 @@ fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx, bool non
*/
struct fd_batch *flush_batch = NULL;
for (unsigned i = 0; i < ARRAY_SIZE(cache->batches); i++) {
if ((cache->batches[i] == ctx->batch) ||
!cache->batches[i]->needs_flush)
continue;
if (!flush_batch || (cache->batches[i]->seqno < flush_batch->seqno))
fd_batch_reference_locked(&flush_batch, cache->batches[i]);
}

View File

@@ -385,9 +385,6 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
goto fail;
pctx->const_uploader = pctx->stream_uploader;
if (!ctx->screen->reorder)
ctx->batch = fd_bc_alloc_batch(&screen->batch_cache, ctx, false);
slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
fd_draw_init(pctx);

View File

@@ -256,7 +256,6 @@ fd_set_framebuffer_state(struct pipe_context *pctx,
DBG("%d: cbufs[0]=%p, zsbuf=%p", ctx->batch->needs_flush,
framebuffer->cbufs[0], framebuffer->zsbuf);
fd_batch_flush(ctx->batch);
util_copy_framebuffer_state(&ctx->batch->framebuffer, cso);
}
ctx->dirty |= FD_DIRTY_FRAMEBUFFER;