From: Eric Anholt Date: Tue, 12 May 2020 16:39:20 +0000 (-0700) Subject: freedreno: Skip taking the lock for resource usage if it's already flagged. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a663c595bc19d627d2fd28081412306b91554d96;p=mesa.git 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: --- 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);