freedreno: Add an early out for preparing to read a resource.
authorEric Anholt <eric@anholt.net>
Mon, 11 May 2020 20:46:33 +0000 (13:46 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 12 May 2020 21:19:50 +0000 (21:19 +0000)
nohw drawoverhead 8 UBOs test throughput 1.06093% +/- 0.363376% (n=10).

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

src/gallium/drivers/freedreno/freedreno_batch.c

index a653e0d91a8f1eeeb56b4c05aa8c9050579af87b..3ee150fce75d1ab2d0bdf0588df62efede6f9765 100644 (file)
@@ -460,6 +460,13 @@ fd_batch_resource_read(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);