From 09e1fb2bceb650d700bf94f668c116ec93a58319 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 15 Jun 2021 10:43:11 -0700 Subject: [PATCH] freedreno: Move the !MAP_WRITE write batch refcounting to the branch. For MAP_WRITE, we flush all the batches referencing the BO, so the write batch will get flushed anyway. No need to take an extra ref. Part-of: --- src/gallium/drivers/freedreno/freedreno_resource.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index d3981c1..59408c6 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -664,12 +664,6 @@ static void flush_resource(struct fd_context *ctx, struct fd_resource *rsc, unsigned usage) assert_dt { - struct fd_batch *write_batch = NULL; - - fd_screen_lock(ctx->screen); - fd_batch_reference_locked(&write_batch, rsc->track->write_batch); - fd_screen_unlock(ctx->screen); - if (usage & PIPE_MAP_WRITE) { struct fd_batch *batch, *batches[32] = {}; uint32_t batch_count = 0; @@ -688,11 +682,16 @@ flush_resource(struct fd_context *ctx, struct fd_resource *rsc, fd_batch_flush(batches[i]); fd_batch_reference(&batches[i], NULL); } - } else if (write_batch) { - fd_batch_flush(write_batch); + } else { + struct fd_batch *write_batch = NULL; + fd_screen_lock(ctx->screen); + fd_batch_reference_locked(&write_batch, rsc->track->write_batch); + fd_screen_unlock(ctx->screen); + if (write_batch) { + fd_batch_flush(write_batch); + fd_batch_reference(&write_batch, NULL); + } } - - fd_batch_reference(&write_batch, NULL); } static void -- 2.7.4