Mesa (master): freedreno: Move the resource_read early out to an inline.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 12 21:38:57 UTC 2020


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon May 11 15:08:35 2020 -0700

freedreno: Move the resource_read early out to an inline.

Looking at perf, the drawoverhead test case was now spending 13% CPU (89%
in that function) on stack management.

nohw drawoverhead throughput 1.03902% +/- 0.380257% (n=13).

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4996>

---

 src/gallium/drivers/freedreno/freedreno_batch.c    | 15 +--------------
 src/gallium/drivers/freedreno/freedreno_batch.h    |  2 +-
 src/gallium/drivers/freedreno/freedreno_resource.h | 18 ++++++++++++++++++
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c
index 3ee150fce75..288f3307ad3 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch.c
@@ -392,12 +392,6 @@ flush_write_batch(struct fd_resource *rsc)
 	fd_batch_reference_locked(&b, NULL);
 }
 
-static bool
-fd_batch_references_resource(struct fd_batch *batch, struct fd_resource *rsc)
-{
-	return rsc->batch_mask & (1 << batch->idx);
-}
-
 static void
 fd_batch_add_resource(struct fd_batch *batch, struct fd_resource *rsc)
 {
@@ -456,17 +450,10 @@ fd_batch_resource_write(struct fd_batch *batch, struct fd_resource *rsc)
 }
 
 void
-fd_batch_resource_read(struct fd_batch *batch, struct fd_resource *rsc)
+fd_batch_resource_read_slowpath(struct fd_batch *batch, struct fd_resource *rsc)
 {
 	fd_screen_assert_locked(batch->ctx->screen);
 
-	/* Early out, if we hit this then we know we don't have anyone else
-	 * writing to it (since both _write and _read flush other writers), and
-	 * that we've already recursed for stencil.
-	 */
-	if (likely(fd_batch_references_resource(batch, rsc)))
-		return;
-
 	if (rsc->stencil)
 		fd_batch_resource_read(batch, rsc->stencil);
 
diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h
index 8ec3700b7ad..6a48c3435ac 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.h
+++ b/src/gallium/drivers/freedreno/freedreno_batch.h
@@ -257,7 +257,7 @@ void fd_batch_reset(struct fd_batch *batch);
 void fd_batch_flush(struct fd_batch *batch);
 void fd_batch_add_dep(struct fd_batch *batch, struct fd_batch *dep);
 void fd_batch_resource_write(struct fd_batch *batch, struct fd_resource *rsc);
-void fd_batch_resource_read(struct fd_batch *batch, struct fd_resource *rsc);
+void fd_batch_resource_read_slowpath(struct fd_batch *batch, struct fd_resource *rsc);
 void fd_batch_check_size(struct fd_batch *batch);
 
 /* not called directly: */
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index d1c673996cc..b60b6ee6a30 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -240,4 +240,22 @@ void fd_resource_uncompress(struct fd_context *ctx, struct fd_resource *rsc);
 
 bool fd_render_condition_check(struct pipe_context *pctx);
 
+static inline bool
+fd_batch_references_resource(struct fd_batch *batch, struct fd_resource *rsc)
+{
+	return rsc->batch_mask & (1 << batch->idx);
+}
+
+static inline void
+fd_batch_resource_read(struct fd_batch *batch,
+		struct fd_resource *rsc)
+{
+	/* Fast path: if we hit this then we know we don't have anyone else
+	 * writing to it (since both _write and _read flush other writers), and
+	 * that we've already recursed for stencil.
+	 */
+	if (unlikely(!fd_batch_references_resource(batch, rsc)))
+		fd_batch_resource_read_slowpath(batch, rsc);
+}
+
 #endif /* FREEDRENO_RESOURCE_H_ */



More information about the mesa-commit mailing list