mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-25 01:30:30 +01:00
mesa: Implement _mesa_flsll().
This is _mesa_fls() for 64-bit values. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
4b38c5c783
commit
3d166b313d
1 changed files with 24 additions and 0 deletions
|
|
@ -433,6 +433,30 @@ _mesa_fls(unsigned int n)
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the last (most significant) bit set in a uint64_t value.
|
||||
*
|
||||
* Essentially ffsll() in the reverse direction.
|
||||
*/
|
||||
static inline unsigned int
|
||||
_mesa_flsll(uint64_t n)
|
||||
{
|
||||
#ifdef HAVE___BUILTIN_CLZLL
|
||||
return n == 0 ? 0 : 64 - __builtin_clzll(n);
|
||||
#else
|
||||
unsigned int v = 1;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
while (n >>= 1)
|
||||
v++;
|
||||
|
||||
return v;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
extern GLhalfARB
|
||||
_mesa_float_to_half(float f);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue