diff --git a/src/common/Math.cpp b/src/common/Math.cpp index e0de2ce2eb..aab0e451ce 100644 --- a/src/common/Math.cpp +++ b/src/common/Math.cpp @@ -59,11 +59,11 @@ uint32_t Log2(uint64_t value) { #endif } -uint64_t NextPowerOfTwo(uint64_t x) { +uint64_t NextPowerOfTwo(uint64_t n) { #if defined(DAWN_COMPILER_MSVC) - return x == 1 ? 1 : 1ull << (64 - __lzcnt64(x - 1)); + return n <= 1 ? 1 : 1ull << (64 - __lzcnt64(n - 1)); #else - return x == 1 ? 1 : 1ull << (64 - __builtin_clzll(x - 1)); + return n == 1 ? 1 : 1ull << (64 - __builtin_clzll(n - 1)); #endif } diff --git a/src/common/Math.h b/src/common/Math.h index 777edba961..80b8792eb1 100644 --- a/src/common/Math.h +++ b/src/common/Math.h @@ -28,7 +28,7 @@ uint32_t Log2(uint32_t value); uint32_t Log2(uint64_t value); bool IsPowerOfTwo(size_t n); -uint64_t NextPowerOfTwo(uint64_t x); +uint64_t NextPowerOfTwo(uint64_t n); bool IsPtrAligned(const void* ptr, size_t alignment); void* AlignVoidPtr(void* ptr, size_t alignment); bool IsAligned(uint32_t value, size_t alignment);