diff --git a/src/common/align.h b/src/common/align.h index f6883f08..e2d8fb39 100644 --- a/src/common/align.h +++ b/src/common/align.h @@ -21,22 +21,7 @@ constexpr T AlignUpPow2(T value, unsigned int alignment) { return (value + static_cast(alignment - 1)) & static_cast(~static_cast(alignment - 1)); } -template -constexpr T AlignDownPow2(T value, unsigned int alignment) -{ - return value & static_cast(~static_cast(alignment - 1)); -} #define IS_POW2(value) (((value) & ((value) - 1)) == 0) -template -constexpr T PreviousPow2(T value) -{ - value |= (value >> 1); - value |= (value >> 2); - value |= (value >> 4); - value |= (value >> 8); - value |= (value >> 16); - return value - (value >> 1); -} } // namespace Common diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 95751919..3037ce36 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -191,6 +191,16 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed) UpdateSoftwareRenderer(true); } +static u32 PreviousPow2(u32 value) +{ + value |= (value >> 1); + value |= (value >> 2); + value |= (value >> 4); + value |= (value >> 8); + value |= (value >> 16); + return value - (value >> 1); +} + u32 GPU_HW::CalculateResolutionScale() const { u32 scale; @@ -210,7 +220,7 @@ u32 GPU_HW::CalculateResolutionScale() const } if (g_settings.gpu_downsample_mode == GPUDownsampleMode::Adaptive && m_supports_adaptive_downsampling && scale > 1 && !(IS_POW2(scale))) - return Common::PreviousPow2(scale); + return PreviousPow2(scale); return scale; } diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index 2204a8af..10ff1efd 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -126,13 +126,18 @@ ALWAYS_INLINE u32 VRAM16ToOutput(u16 value) return ZeroExtend32(b) | (ZeroExtend32(g) << 8) | (ZeroExtend32(r) << 16) | (0xFF000000u); } +static u32 AlignDownPow2(u32 value, unsigned int alignment) +{ + return value & (~(alignment - 1)); +} + template<> ALWAYS_INLINE void CopyOutRow16(const u16* src_ptr, u16* dst_ptr, u32 width) { u32 col = 0; #if defined(CPU_X64) - const u32 aligned_width = Common::AlignDownPow2(width, 8); + const u32 aligned_width = AlignDownPow2(width, 8); for (; col < aligned_width; col += 8) { const __m128i single_mask = _mm_set1_epi16(0x1F); @@ -146,7 +151,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16 dst_ptr += 8; } #elif defined(CPU_AARCH64) - const u32 aligned_width = Common::AlignDownPow2(width, 8); + const u32 aligned_width = AlignDownPow2(width, 8); for (; col < aligned_width; col += 8) { const uint16x8_t single_mask = vdupq_n_u16(0x1F); @@ -171,7 +176,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16* u32 col = 0; #if defined(CPU_X64) - const u32 aligned_width = Common::AlignDownPow2(width, 8); + const u32 aligned_width = AlignDownPow2(width, 8); for (; col < aligned_width; col += 8) { const __m128i single_mask = _mm_set1_epi16(0x1F); @@ -186,7 +191,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16* dst_ptr += 8; } #elif defined(CPU_AARCH64) - const u32 aligned_width = Common::AlignDownPow2(width, 8); + const u32 aligned_width = AlignDownPow2(width, 8); const uint16x8_t single_mask = vdupq_n_u16(0x1F); for (; col < aligned_width; col += 8) {