diff options
author | Kenneth Graunke <[email protected]> | 2015-03-30 16:08:26 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2015-04-01 13:30:13 -0700 |
commit | 3d166b313db14523c2e618e0ebf22b83c86d6334 (patch) | |
tree | 8de3def38fe54665cf6b9a18a4ec54e3a423e4e9 /src/mesa/main | |
parent | 4b38c5c783e8858f362bb1ff6cf651875bd0bbc5 (diff) |
mesa: Implement _mesa_flsll().
This is _mesa_fls() for 64-bit values.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/imports.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 29f249980a0..c4d917ebba4 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -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); |