From 1b8e75e90b75bae1387d5a3dacbe2e2c9337bebf Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 21 Jan 2024 23:50:08 +0100 Subject: [PATCH] Take widescreen hack into account when determining automatic resolution scale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At widescreen aspect ratios, a greater resolution scale factor is required to maintain crisp visuals. For instance, a 16:9 output requires ~1.333× the resolution scale of a 4:3 output (as 16:9 is ~1.333× wider than 4:3). This improves visuals at widescreen aspect ratios when the widescreen hack is enabled, especially for ultrawide. --- src/core/gpu_hw.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index e3f95967d..d8f81fff4 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -525,8 +525,17 @@ u32 GPU_HW::CalculateResolutionScale() const static_cast(m_crtc_state.display_height) : (m_console_is_pal ? (PAL_VERTICAL_ACTIVE_END - PAL_VERTICAL_ACTIVE_START) : (NTSC_VERTICAL_ACTIVE_END - NTSC_VERTICAL_ACTIVE_START)); + + float widescreen_multiplier = 1.0f; + if (g_settings.gpu_widescreen_hack) { + // Multiply scale factor by aspect ratio relative to 4:3, so that widescreen resolution is as close as possible to native screen resolution. + // Otherwise, anamorphic stretching would result in increasingly less horizontal resolution (relative to native screen resolution) + // as the aspect ratio gets wider. + widescreen_multiplier = std::max(1.0, (float(g_gpu_device->GetWindowWidth()) / g_gpu_device->GetWindowHeight()) / (4.0 / 3.0)); + } + const s32 preferred_scale = - static_cast(std::ceil(static_cast(g_gpu_device->GetWindowHeight()) / height)); + static_cast(std::ceil(static_cast(g_gpu_device->GetWindowHeight() * widescreen_multiplier) / height)); Log_VerboseFmt("Height = {}, preferred scale = {}", height, preferred_scale); scale = static_cast(std::clamp(preferred_scale, 1, max_resolution_scale));