Mesa (master): freedreno: Skip taking the lock for resource usage if it's already flagged.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 12 22:11:26 UTC 2020


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

Author: Eric Anholt <eric at anholt.net>
Date:   Tue May 12 09:39:20 2020 -0700

freedreno: Skip taking the lock for resource usage if it's already flagged.

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 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index b60b6ee6a30..f71cd6a8617 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -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);



More information about the mesa-commit mailing list