diff options
| author | Filoppi <filippotarpini@hotmail.it> | 2023-06-27 12:45:19 +0300 |
|---|---|---|
| committer | Filoppi <filippotarpini@hotmail.it> | 2023-08-18 02:14:00 +0300 |
| commit | 8bca9a864fc1739aced3c91ea7dfeef3f5516eca (patch) | |
| tree | 6c71e9d63ea901028654f505868ec4f8624b2f5c /Source/Core/VideoCommon/Present.cpp | |
| parent | 6c7f34d5da28475a4d1eb9e67ffd1617cbd501b3 (diff) | |
Video: The `Auto` internal resolution scaling wasn't working correctly if the window weird aspect ratios (e.g. 32:9), beacuse it would account for the the portion of the image that will show black bars into the calcuations to find the best matching resolution
Diffstat (limited to 'Source/Core/VideoCommon/Present.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Present.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp index 53d0d737d0..a190231faa 100644 --- a/Source/Core/VideoCommon/Present.cpp +++ b/Source/Core/VideoCommon/Present.cpp @@ -365,9 +365,34 @@ void* Presenter::GetNewSurfaceHandle() u32 Presenter::AutoIntegralScale() const { - // Calculate a scale based on the window size - u32 width = EFB_WIDTH * m_target_rectangle.GetWidth() / m_last_xfb_width; - u32 height = EFB_HEIGHT * m_target_rectangle.GetHeight() / m_last_xfb_height; + 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)); + } + 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); } |
