freedreno: allow ctx->batch to be NULL
authorRob Clark <robdclark@chromium.org>
Tue, 4 Feb 2020 21:46:56 +0000 (13:46 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 4 Feb 2020 23:59:33 +0000 (23:59 +0000)
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>

src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_batch_cache.c
src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_state.c

index dc8e17915133e1709abbd19ef87c63cd0c28e2e6..8f3f7827ce326dde61389ae307684573d2b9b030 100644 (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);
index ec1d1acf9b324c56b53b45c7397820688c25ce36..f86e75e8b8998136bb02cbb9f6e1eeaa5f15b9c0 100644 (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]);
                }
index e396d61c6cbca814f09c0a384e8353f3e96f47f0..fc7ecff0e7dbb2c2f082e8c3af1bc773a312930b 100644 (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);
index a231441d314a09970f5a5a0016b2640d0440bfb7..8a757ee96d4a37c7e32b13a55c006f80c174c20a 100644 (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;