summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_math.h
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2009-07-22 15:08:42 +0100
committerKeith Whitwell <keithw@vmware.com>2009-07-22 15:08:42 +0100
commitf911c3b9897b90132c8621a72bfeb824eb3b01e5 (patch)
tree61243e5d616101304ffa36ad982b7c6e6da2e7b6 /src/gallium/auxiliary/util/u_math.h
parent13e2d35764e0c8de3356ee663885568fc00424f0 (diff)
softpipe: shortcircuit repeated lookups of the same tile
The sp_tile_cache is often called repeatedly to look up the same tile. Add a cache (to the cache) of the single tile most recently retreived and make a quick inline check to see if this matches the subsequent request. Add a tile_address bitfield struct to make this check easier.
Diffstat (limited to 'src/gallium/auxiliary/util/u_math.h')
-rw-r--r--src/gallium/auxiliary/util/u_math.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index e5003af01d..d30fa3c2d5 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -366,6 +366,18 @@ unsigned ffs( unsigned u )
#endif
+/* Could also binary search for the highest bit.
+ */
+static INLINE unsigned
+util_unsigned_logbase2(unsigned n)
+{
+ unsigned log2 = 0;
+ while (n >>= 1)
+ ++log2;
+ return log2;
+}
+
+
/**
* Return float bits.
*/