[Mesa-dev] [PATCH] gallium/util: fix u_bit_scan_consecutive_range for mask == 0xffffffff

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Fri Apr 15 22:40:57 UTC 2016


On Sat, Apr 16, 2016 at 12:34 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> The second ffs returns 0, yielding count == -1.
> ---
>  src/gallium/auxiliary/util/u_math.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
> index b4ac0db..2880eea 100644
> --- a/src/gallium/auxiliary/util/u_math.h
> +++ b/src/gallium/auxiliary/util/u_math.h
> @@ -518,6 +518,12 @@ u_bit_scan64(uint64_t *mask)
>  static inline void
>  u_bit_scan_consecutive_range(unsigned *mask, int *start, int *count)
>  {
> +   if (*mask == 0xffffffff) {
> +      *start = 0;
> +      *count = 32;
> +      *mask = 0;
> +      return;
> +   }
>     *start = ffs(*mask) - 1;
>     *count = ffs(~(*mask >> *start)) - 1;
>     *mask &= ~(((1 << *count) - 1) << *start);

This signed shift needs to be fixed for *count == 31 too. Either way,

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

> --
> 2.5.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list