[Mesa-dev] [PATCH] gallium/util: fix u_bit_scan_consecutive_range for mask == 0xffffffff
Marek Olšák
maraeo at gmail.com
Fri Apr 15 22:34:37 UTC 2016
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);
--
2.5.0
More information about the mesa-dev
mailing list