From 853e2b90a3a63e1390695702db2c62e62bf02052 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 13 Aug 2020 23:09:51 +0300 Subject: [PATCH] rsx: Minor rsx::ceil_log2 bugfix --- rpcs3/Emu/RSX/rsx_utils.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 7aca04b738..ed80b6120b 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -245,18 +245,17 @@ namespace rsx } } - // - static inline u32 floor_log2(u32 value) + static constexpr u32 floor_log2(u32 value) { return value <= 1 ? 0 : std::countl_zero(value) ^ 31; } - static inline u32 ceil_log2(u32 value) + static constexpr u32 ceil_log2(u32 value) { - return value <= 1 ? 0 : std::countl_zero((value - 1) << 1) ^ 31; + return floor_log2(value) + u32{!!(value & (value - 1))}; } - static inline u32 next_pow2(u32 x) + static constexpr u32 next_pow2(u32 x) { if (x <= 2) return x;