Bladeren bron

gallium/util: add util_bit_last - finds the last bit set in a word

tags/rgb10_a2ui-v3
Marek Olšák 13 jaren geleden
bovenliggende
commit
6694a68d89
1 gewijzigde bestanden met toevoegingen van 14 en 0 verwijderingen
  1. 14
    0
      src/gallium/auxiliary/util/u_math.h

+ 14
- 0
src/gallium/auxiliary/util/u_math.h Bestand weergeven

@@ -477,6 +477,20 @@ unsigned ffs( unsigned u )

#endif /* FFS_DEFINED */

/**
* Find last bit set in a word. The least significant bit is 1.
* Return 0 if no bits are set.
*/
static INLINE unsigned util_last_bit(unsigned u)
{
unsigned r = 0;
while (u) {
r++;
u >>= 1;
}
return r;
}


/* Destructively loop over all of the bits in a mask as in:
*

Laden…
Annuleren
Opslaan