diff options
author | marha <marha@users.sourceforge.net> | 2011-06-09 09:27:21 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-06-09 09:27:21 +0200 |
commit | 0de14292c4fac98f91105baf9cc16e58f25d4d77 (patch) | |
tree | 1704165c3d7f05bde08dc6d3d52ee33aed0f270f /mesalib/src/gallium/auxiliary/util/u_math.h | |
parent | 637bc31135b378ea9521b5a93b14bdce482da209 (diff) | |
parent | 0a9d2abef2e6fac5d52556969655a62711df6418 (diff) | |
download | vcxsrv-0de14292c4fac98f91105baf9cc16e58f25d4d77.tar.gz vcxsrv-0de14292c4fac98f91105baf9cc16e58f25d4d77.tar.bz2 vcxsrv-0de14292c4fac98f91105baf9cc16e58f25d4d77.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
mesalib/include/GL/internal/dri_interface.h
mesalib/src/gallium/auxiliary/util/u_math.h
mesalib/src/mapi/glapi/gen/Makefile
mesalib/src/mapi/glapi/gen/gl_table.py
mesalib/src/mesa/SConscript
mesalib/src/mesa/main/dlist.c
mesalib/src/mesa/main/es_generator.py
mesalib/src/mesa/main/imports.h
mesalib/src/mesa/main/teximage.c
mesalib/src/mesa/main/uniforms.c
mesalib/src/mesa/state_tracker/st_draw.c
mesalib/src/mesa/state_tracker/st_program.c
mesalib/src/mesa/vbo/vbo_save_api.c
xorg-server/xkeyboard-config/configure.in
xorg-server/xkeyboard-config/rules/Makefile.am
xorg-server/xkeyboard-config/rules/base.xml.in
xorg-server/xkeyboard-config/symbols/cz
xorg-server/xkeyboard-config/symbols/in
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util/u_math.h')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index b37d62175..9a061e8a9 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -477,6 +477,9 @@ float_to_byte_tex(float f) static INLINE unsigned
util_logbase2(unsigned n)
{
+#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 304)
+ return ((sizeof(unsigned) * 8 - 1) - __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 +487,7 @@ util_logbase2(unsigned n) if (n >= 1<< 2) { n >>= 2; pos += 2; }
if (n >= 1<< 1) { pos += 1; }
return pos;
+#endif
}
@@ -493,17 +497,29 @@ util_logbase2(unsigned n) static INLINE unsigned
util_next_power_of_two(unsigned x)
{
- unsigned i;
-
- if (x == 0)
- return 1;
+#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 304)
+ if (x <= 1)
+ return 1;
- --x;
+ return (1 << ((sizeof(unsigned) * 8) - __builtin_clz(x - 1)));
+#else
+ unsigned val = x;
- for (i = 1; i < sizeof(unsigned) * 8; i <<= 1)
- x |= x >> i;
+ if (x <= 1)
+ return 1;
- return x + 1;
+ if (util_is_power_of_two(x))
+ return x;
+
+ val--;
+ val = (val >> 1) | val;
+ val = (val >> 2) | val;
+ val = (val >> 4) | val;
+ val = (val >> 8) | val;
+ val = (val >> 16) | val;
+ val++;
+ return val;
+#endif
}
@@ -513,7 +529,7 @@ util_next_power_of_two(unsigned x) static INLINE unsigned
util_bitcount(unsigned n)
{
-#if defined(PIPE_CC_GCC)
+#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 304)
return __builtin_popcount(n);
#else
/* K&R classic bitcount.
|