projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bab3b4a
)
util: faster logbase2
author
Brian Paul
<brianp@vmware.com>
Thu, 2 Jun 2011 14:43:07 +0000
(08:43 -0600)
committer
Brian Paul
<brianp@vmware.com>
Thu, 2 Jun 2011 14:45:27 +0000
(08:45 -0600)
src/gallium/auxiliary/util/u_math.h
patch
|
blob
|
history
diff --git
a/src/gallium/auxiliary/util/u_math.h
b/src/gallium/auxiliary/util/u_math.h
index 2ecade5f7e47b766a021197c2d93e0f36648505b..65a99fcb394ff2f208a36551142ef9d03f7ac817 100644
(file)
--- a/
src/gallium/auxiliary/util/u_math.h
+++ b/
src/gallium/auxiliary/util/u_math.h
@@
-477,10
+477,13
@@
float_to_byte_tex(float f)
static INLINE unsigned
util_logbase2(unsigned n)
{
- unsigned log2 = 0;
- while (n >>= 1)
- ++log2;
- return log2;
+ unsigned pos = 0;
+ if (n >= 1<<16) { n >>= 16; pos += 16; }
+ if (n >= 1<< 8) { n >>= 8; pos += 8; }
+ if (n >= 1<< 4) { n >>= 4; pos += 4; }
+ if (n >= 1<< 2) { n >>= 2; pos += 2; }
+ if (n >= 1<< 1) { pos += 1; }
+ return pos;
}