Mesa (staging/20.0): freedreno: allow ctx->batch to be NULL
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 5 17:05:47 UTC 2020
Module: Mesa
Branch: staging/20.0
Commit: c937b846437723bf4ead3447bef716aa1d252816
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c937b846437723bf4ead3447bef716aa1d252816
Author: Rob Clark <robdclark at chromium.org>
Date: Tue Feb 4 13:46:56 2020 -0800
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 at lists.freedesktop.org
Signed-off-by: Rob Clark <robdclark at 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>
(cherry picked from commit 2c07e03b792d57ae807a6953f0d8ff5f4bcdffd0)
---
.pick_status.json | 2 +-
src/gallium/drivers/freedreno/freedreno_batch.c | 25 ++--------------------
.../drivers/freedreno/freedreno_batch_cache.c | 3 ---
src/gallium/drivers/freedreno/freedreno_context.c | 3 ---
src/gallium/drivers/freedreno/freedreno_state.c | 1 -
5 files changed, 3 insertions(+), 31 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index f9a84aff49b..25133ec567b 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -202,7 +202,7 @@
"description": "freedreno: allow ctx->batch to be NULL",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
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;
More information about the mesa-commit
mailing list