From f179594cf9a937dea3ac1e9d0b1d6d3fc86a8af3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 25 Jan 2021 14:54:25 -0800 Subject: [PATCH] freedreno: Early-out from the resource write path when we're the writer. No need to do the other checks in this case, because then we know that we've done the UBWC clears and recursed on stencil and added deps on read batches. Done as a separate patch to reduce behavior changes in my upcoming move of the batch cache to the context. Part-of: --- src/gallium/drivers/freedreno/freedreno_batch.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index e2e3d975cdd..8d67c620cf5 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -451,15 +451,21 @@ fd_batch_resource_write(struct fd_batch *batch, struct fd_resource *rsc) { fd_screen_assert_locked(batch->ctx->screen); + DBG("%p: write %p", batch, rsc); + + /* Must do this before the early out, so we unset a previous resource + * invalidate (which may have left the write_batch state in place). + */ + rsc->valid = true; + + if (rsc->write_batch == batch) + return; + fd_batch_write_prep(batch, rsc); if (rsc->stencil) fd_batch_resource_write(batch, rsc->stencil); - DBG("%p: write %p", batch, rsc); - - rsc->valid = true; - /* note, invalidate write batch, to avoid further writes to rsc * resulting in a write-after-read hazard. */ @@ -468,7 +474,7 @@ fd_batch_resource_write(struct fd_batch *batch, struct fd_resource *rsc) struct fd_batch_cache *cache = &batch->ctx->screen->batch_cache; struct fd_batch *dep; - if (rsc->write_batch && rsc->write_batch != batch) + if (rsc->write_batch) flush_write_batch(rsc); foreach_batch(dep, cache, rsc->batch_mask) {