freedreno: Move the resource_read early out to an inline.
authorEric Anholt <eric@anholt.net>
Mon, 11 May 2020 22:08:35 +0000 (15:08 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 12 May 2020 21:19:50 +0000 (21:19 +0000)
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
src/gallium/drivers/freedreno/freedreno_batch.h
src/gallium/drivers/freedreno/freedreno_resource.h

index 3ee150fce75d1ab2d0bdf0588df62efede6f9765..288f3307ad345d1929c104cbdce0bc4929fbc6b0 100644 (file)
@@ -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);
 
index 8ec3700b7adb9109542b048a0c605d7b7e71ffe4..6a48c3435acd608331d6a2453d6d8734922fea72 100644 (file)
@@ -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: */
index d1c673996cc20a8ca00ff7ebbabf86a55c503404..b60b6ee6a30bc819737a422ae5aef3264e45b9a9 100644 (file)
@@ -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_ */