Mesa (master): freedreno: Early-out from the resource write path when we're the writer.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 23:03:30 UTC 2021


Module: Mesa
Branch: master
Commit: f179594cf9a937dea3ac1e9d0b1d6d3fc86a8af3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f179594cf9a937dea3ac1e9d0b1d6d3fc86a8af3

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jan 25 14:54:25 2021 -0800

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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8729>

---

 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) {



More information about the mesa-commit mailing list