On a Roland Scheidegger idea!
Benjamin
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 3e42911..da2e72f 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -86,6 +86,12 @@ _mesa_free_texmemory(void *m) static GLuint logbase2(GLuint n) { +#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 340) + if (n <= 1) + return 0; + + return (31 - __builtin_clz(n | 1)); +#else GLuint pos = 0; if (n >= 1<<16) { n >>= 16; pos += 16; } if (n >= 1<< 8) { n >>= 8; pos += 8; } @@ -93,6 +99,7 @@ logbase2(GLuint n) if (n >= 1<< 2) { n >>= 2; pos += 2; } if (n >= 1<< 1) { pos += 1; } return pos; +#endif }
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 65a99fc..cde9c92 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -477,6 +477,12 @@ float_to_byte_tex(float f) static INLINE unsigned util_logbase2(unsigned n) { +#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 340) + if (n <= 1) + return 0; + + return (31 - __builtin_clz(n | 1)); +#else unsigned pos = 0; if (n >= 1<<16) { n >>= 16; pos += 16; } if (n >= 1<< 8) { n >>= 8; pos += 8; } @@ -484,6 +490,7 @@ util_logbase2(unsigned n) if (n >= 1<< 2) { n >>= 2; pos += 2; } if (n >= 1<< 1) { pos += 1; } return pos; +#endif }
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev