diff options
author | Pauli Nieminen <[email protected]> | 2010-02-07 07:36:13 +0200 |
---|---|---|
committer | Pauli Nieminen <[email protected]> | 2010-02-07 13:13:24 +0200 |
commit | 1a45c2bce7480ef1d125439aed8413bcff0ab468 (patch) | |
tree | 7fffda88306f529a2fd1efb38d0101a5653c23ff /src/mesa | |
parent | ce1f351963ae1de1218c83c9f846a17c2e3db65e (diff) |
mesa: Fix mesa_next_pow_two to return same value if parameter is pow2.
Without subtracting one pow2 value would be rounded up to next pow2
which is not correct behaviour for the function.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/imports.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 81cb396b2bb..3843f50036c 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -417,7 +417,8 @@ static INLINE int32_t _mesa_next_pow_two_32(uint32_t x) { #ifdef __GNUC__ - return 1 << (__builtin_clz(x) ^ 31); + x--; + return 1 << ((__builtin_clz(x) ^ 31) + 1); #else x--; x |= x >> 1; @@ -434,10 +435,11 @@ static INLINE int64_t _mesa_next_pow_two_64(uint64_t x) { #ifdef __GNUC__ + x--; if (sizeof(x) == sizeof(long)) - return 1 << (__builtin_clzl(x) ^ 63); + return 1 << ((__builtin_clzl(x) ^ 63) + 1); else - return 1 << (__builtin_clzll(x) ^ 63); + return 1 << ((__builtin_clzll(x) ^ 63) + 1); #else x--; x |= x >> 1; |