diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/arrayobj.c | 5 | ||||
-rw-r--r-- | src/mesa/main/buffers.c | 7 | ||||
-rw-r--r-- | src/mesa/main/imports.c | 38 | ||||
-rw-r--r-- | src/mesa/main/imports.h | 15 |
4 files changed, 7 insertions, 58 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 6e0665c0e5d..ad34282afc8 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -53,6 +53,7 @@ #include "varray.h" #include "util/bitscan.h" #include "util/u_atomic.h" +#include "util/u_math.h" const GLubyte @@ -755,7 +756,7 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx, * grouping information in a seperate array beside * gl_array_attributes/gl_vertex_buffer_binding. */ - assert(_mesa_bitcount(binding->_BoundArrays & vao->_Enabled) == 1 + assert(util_bitcount(binding->_BoundArrays & vao->_Enabled) == 1 || (vao->_Enabled & ~binding->_BoundArrays) == 0); /* Start this current effective binding with the array */ @@ -775,7 +776,7 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx, &vao->BufferBinding[attrib2->BufferBindingIndex]; /* See the comment at the same assert above. */ - assert(_mesa_bitcount(binding2->_BoundArrays & vao->_Enabled) == 1 + assert(util_bitcount(binding2->_BoundArrays & vao->_Enabled) == 1 || (vao->_Enabled & ~binding->_BoundArrays) == 0); /* Check if we have an identical binding */ diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index bb856882da2..d98c015bb24 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -37,6 +37,7 @@ #include "fbobject.h" #include "mtypes.h" #include "util/bitscan.h" +#include "util/u_math.h" #define BAD_MASK ~0u @@ -468,7 +469,7 @@ draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb, GLsizei n, * For OpenGL 4.x we check that behaviour. For any previous version we * keep considering it wrong (as INVALID_ENUM). */ - if (_mesa_bitcount(destMask[output]) > 1) { + if (util_bitcount(destMask[output]) > 1) { if (_mesa_is_winsys_fbo(fb) && ctx->Version >= 40 && buffers[output] == GL_BACK) { if (n != 1) { @@ -722,7 +723,7 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, * (ex: glDrawBuffer(GL_FRONT_AND_BACK)). * Otherwise, destMask[x] can only have one bit set. */ - if (n > 0 && _mesa_bitcount(destMask[0]) > 1) { + if (n > 0 && util_bitcount(destMask[0]) > 1) { GLuint count = 0, destMask0 = destMask[0]; while (destMask0) { const gl_buffer_index bufIndex = u_bit_scan(&destMask0); @@ -741,7 +742,7 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, if (destMask[buf]) { gl_buffer_index bufIndex = ffs(destMask[buf]) - 1; /* only one bit should be set in the destMask[buf] field */ - assert(_mesa_bitcount(destMask[buf]) == 1); + assert(util_bitcount(destMask[buf]) == 1); if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) { updated_drawbuffers(ctx, fb); fb->_ColorDrawBufferIndexes[buf] = bufIndex; diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index b4685b6dc35..566aac1d385 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -213,44 +213,6 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, /*@}*/ -/**********************************************************************/ -/** \name Math */ -/*@{*/ - - -#ifndef HAVE___BUILTIN_POPCOUNT -/** - * Return number of bits set in given GLuint. - */ -unsigned int -_mesa_bitcount(unsigned int n) -{ - unsigned int bits; - for (bits = 0; n > 0; n = n >> 1) { - bits += (n & 1); - } - return bits; -} -#endif - -#ifndef HAVE___BUILTIN_POPCOUNTLL -/** - * Return number of bits set in given 64-bit uint. - */ -unsigned int -_mesa_bitcount_64(uint64_t n) -{ - unsigned int bits; - for (bits = 0; n > 0; n = n >> 1) { - bits += (n & 1); - } - return bits; -} -#endif - -/*@}*/ - - /** Needed due to #ifdef's, above. */ int _mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list args) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index a761f01851a..f461b1c052e 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -317,21 +317,6 @@ extern void * _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, unsigned long alignment); -#ifdef HAVE___BUILTIN_POPCOUNT -#define _mesa_bitcount(i) __builtin_popcount(i) -#else -extern unsigned int -_mesa_bitcount(unsigned int n); -#endif - -#ifdef HAVE___BUILTIN_POPCOUNTLL -#define _mesa_bitcount_64(i) __builtin_popcountll(i) -#else -extern unsigned int -_mesa_bitcount_64(uint64_t n); -#endif - - extern int _mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); |