From 553930424dec0cb1a83d2c928c260de6626b0d11 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 21 Sep 2011 11:22:43 -0600 Subject: [PATCH] util: add u_bit_scan helper --- src/gallium/auxiliary/util/u_math.h | 16 ++++++++++++++++ src/gallium/drivers/llvmpipe/lp_rast_debug.c | 7 ------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 46d9322932a..c74c1da7675 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -424,6 +424,22 @@ unsigned ffs( unsigned u ) #endif +/* Destructively loop over all of the bits in a mask as in: + * + * while (mymask) { + * int i = u_bit_scan(&mymask); + * ... process element i + * } + * + */ +static INLINE int u_bit_scan(unsigned *mask) +{ + int i = ffs(*mask) - 1; + *mask &= ~(1 << i); + return i; +} + + /** * Return float bits. */ diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c b/src/gallium/drivers/llvmpipe/lp_rast_debug.c index b7568ec99c0..86f5f6415e8 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c +++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c @@ -2,13 +2,6 @@ #include "lp_rast_priv.h" #include "lp_state_fs.h" -static INLINE int u_bit_scan(unsigned *mask) -{ - int i = ffs(*mask) - 1; - *mask &= ~(1 << i); - return i; -} - struct tile { int coverage; int overdraw; -- 2.30.2