freedreno: Skip taking the lock for resource usage if it's already flagged.
authorEric Anholt <eric@anholt.net>
Tue, 12 May 2020 16:39:20 +0000 (09:39 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 12 May 2020 21:42:00 +0000 (21:42 +0000)
Improves nohw drawoverhead 8-ubos update throughput by 13.493% +/-
0.391444% (n=15).

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

src/gallium/drivers/freedreno/freedreno_resource.h

index b60b6ee6a30bc819737a422ae5aef3264e45b9a9..f71cd6a86172a39c6220abbdaf7f4db40e7996ce 100644 (file)
@@ -145,6 +145,11 @@ fd_resource_set_usage(struct pipe_resource *prsc, enum fd_dirty_3d_state usage)
        if (!prsc)
                return;
        struct fd_resource *rsc = fd_resource(prsc);
+       /* Bits are only ever ORed in, and we expect many set_usage() per
+        * resource, so do the quick check outside of the lock.
+        */
+       if (likely(rsc->dirty & usage))
+               return;
        fd_resource_lock(rsc);
        rsc->dirty |= usage;
        fd_resource_unlock(rsc);