mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
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.
This commit is contained in:
parent
ce1f351963
commit
1a45c2bce7
1 changed files with 5 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue