mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 15:20:10 +01:00
util: faster logbase2
This commit is contained in:
parent
bab3b4a758
commit
f62e1f41b4
1 changed files with 7 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue