diff options
author | marha <marha@users.sourceforge.net> | 2011-06-03 08:18:04 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-06-03 08:18:04 +0200 |
commit | cda19b1d226d565f1ca4327aeae827c621b3dfd6 (patch) | |
tree | 8a511d718c888b17c257a905607068613359f9a6 /mesalib/src/mesa/main/teximage.c | |
parent | 4d7ec99788d8a1d56ff4bccea279ae8186b18cdc (diff) | |
download | vcxsrv-cda19b1d226d565f1ca4327aeae827c621b3dfd6.tar.gz vcxsrv-cda19b1d226d565f1ca4327aeae827c621b3dfd6.tar.bz2 vcxsrv-cda19b1d226d565f1ca4327aeae827c621b3dfd6.zip |
xserver xkeyboard-config mesa git update 3 Jun 2011
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 4ea9a483c..3e429110a 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -81,31 +81,18 @@ _mesa_free_texmemory(void *m) /* - * Compute floor(log_base_2(n)). - * If n < 0 return -1. + * Returns the floor form of binary logarithm for a 32-bit integer. */ -static int -logbase2( int n ) -{ - GLint i = 1; - GLint log2 = 0; - - if (n < 0) - return -1; - - if (n == 0) - return 0; - - while ( n > i ) { - i *= 2; - log2++; - } - if (i != n) { - return log2 - 1; - } - else { - return log2; - } +static GLuint +logbase2(GLuint n) +{ + GLuint 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; } |