summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Present.cpp
diff options
context:
space:
mode:
authorFiloppi <filippotarpini@hotmail.it>2023-09-07 02:37:34 +0300
committerFiloppi <filippotarpini@hotmail.it>2023-12-18 02:00:25 +0200
commitff03189a60739f4a316bed63da230deb15e98689 (patch)
treedfab71f9f7cce7959a2bdc3e81c5188807f54a0b /Source/Core/VideoCommon/Present.cpp
parentfdd1934f12f684833e158f1859341f887ab4d447 (diff)
Video: fix auto resolution scale calculations
Diffstat (limited to 'Source/Core/VideoCommon/Present.cpp')
-rw-r--r--Source/Core/VideoCommon/Present.cpp45
1 files changed, 17 insertions, 28 deletions
diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp
index 4f208f5119..3dfeebfe00 100644
--- a/Source/Core/VideoCommon/Present.cpp
+++ b/Source/Core/VideoCommon/Present.cpp
@@ -400,35 +400,24 @@ void* Presenter::GetNewSurfaceHandle()
u32 Presenter::AutoIntegralScale() const
{
- const float efb_aspect_ratio = static_cast<float>(EFB_WIDTH) / EFB_HEIGHT;
- const float target_aspect_ratio =
- static_cast<float>(m_target_rectangle.GetWidth()) / m_target_rectangle.GetHeight();
-
- u32 target_width;
- u32 target_height;
-
- // Instead of using the entire window (back buffer) resolution,
- // find the portion of it that will actually contain the EFB output,
- // and ignore the portion that will likely have black bars.
- if (target_aspect_ratio >= efb_aspect_ratio)
- {
- target_height = m_target_rectangle.GetHeight();
- target_width = static_cast<u32>(
- std::round((static_cast<float>(m_target_rectangle.GetWidth()) / target_aspect_ratio) *
- efb_aspect_ratio));
- }
+ // Take the source resolution (XFB) and stretch it on the target aspect ratio.
+ // If the target resolution is larger (on either x or y), we scale the source
+ // by a integer multiplier until it won't have to be scaled up anymore.
+ u32 source_width = m_last_xfb_width;
+ u32 source_height = m_last_xfb_height;
+ const u32 target_width = m_target_rectangle.GetWidth();
+ const u32 target_height = m_target_rectangle.GetHeight();
+ const float source_aspect_ratio = (float)source_width / source_height;
+ const float target_aspect_ratio = (float)target_width / target_height;
+ if (source_aspect_ratio >= target_aspect_ratio)
+ source_width = std::round(source_height * target_aspect_ratio);
else
- {
- target_width = m_target_rectangle.GetWidth();
- target_height = static_cast<u32>(
- std::round((static_cast<float>(m_target_rectangle.GetHeight()) * target_aspect_ratio) /
- efb_aspect_ratio));
- }
-
- // Calculate a scale based on the adjusted window size
- u32 width = EFB_WIDTH * target_width / m_last_xfb_width;
- u32 height = EFB_HEIGHT * target_height / m_last_xfb_height;
- return std::max((width - 1) / EFB_WIDTH + 1, (height - 1) / EFB_HEIGHT + 1);
+ source_height = std::round(source_width / target_aspect_ratio);
+ const u32 width_scale =
+ source_width > 0 ? ((target_width + (source_width - 1)) / source_width) : 1;
+ const u32 height_scale =
+ source_height > 0 ? ((target_height + (source_height - 1)) / source_height) : 1;
+ return std::max(width_scale, height_scale);
}
void Presenter::SetSuggestedWindowSize(int width, int height)