From: Rob Clark Date: Tue, 4 Feb 2020 21:46:56 +0000 (-0800) Subject: freedreno: allow ctx->batch to be NULL X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c07e03b792d57ae807a6953f0d8ff5f4bcdffd0;p=mesa.git 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 Tested-by: Marge Bot Part-of: --- diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index dc8e1791513..8f3f7827ce3 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c index ec1d1acf9b3..f86e75e8b89 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c +++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c @@ -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]); } diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index e396d61c6cb..fc7ecff0e7d 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index a231441d314..8a757ee96d4 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -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;