[Mesa-dev] [PATCH 1/6] mesa: Create a _mesa_bitcount_64() function.

Brian Paul brianp at vmware.com
Tue Oct 4 07:00:10 PDT 2011


On 10/03/2011 04:11 PM, Paul Berry wrote:
> The i965 driver already had a function to do this (brw_count_bits()),
> but it was buggy (it only counted the bottom 32 bits) and it was
> clumsy (it had a strange and broken fallback for non-GCC-like
> compilers, which fortunately was never used).  Since Mesa already has
> a _mesa_bitcount() function, it seems better to just create a
> _mesa_bitcount_64() function rather than special-case this in the i965
> driver.
> ---
>   src/mesa/drivers/dri/i965/brw_util.h |    7 ++-----
>   src/mesa/main/imports.c              |   13 +++++++++++++
>   src/mesa/main/imports.h              |    3 +++
>   3 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_util.h b/src/mesa/drivers/dri/i965/brw_util.h
> index 940a871..bbf36f6 100644
> --- a/src/mesa/drivers/dri/i965/brw_util.h
> +++ b/src/mesa/drivers/dri/i965/brw_util.h
> @@ -34,15 +34,12 @@
>   #define BRW_UTIL_H
>
>   #include "main/mtypes.h"
> +#include "main/imports.h"
>
> -#ifdef __GNUC__
> -#define brw_count_bits(v) __builtin_popcount(v)
> -#else
>   static inline GLuint brw_count_bits(uint64_t v)
>   {
> -	return _mesa_popcount(v>>32) + _mesa_popcount(v&0xffffffff);
> +   return _mesa_bitcount_64(v);
>   }
> -#endif

I'm guessing you could eventually get rid of the brw_count_bits() 
wrapper altogether at some point.

Reviewed-by: Brian Paul <brianp at vmware.com>





More information about the mesa-dev mailing list