diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp index e51d52107c..4f208f5119 100644 --- a/Source/Core/VideoCommon/Present.cpp +++ b/Source/Core/VideoCommon/Present.cpp @@ -13,6 +13,7 @@ #include "Present.h" #include "VideoCommon/AbstractGfx.h" #include "VideoCommon/FrameDumper.h" +#include "VideoCommon/FramebufferManager.h" #include "VideoCommon/OnScreenUI.h" #include "VideoCommon/PostProcessing.h" #include "VideoCommon/Statistics.h" @@ -202,20 +203,46 @@ void Presenter::ProcessFrameDumping(u64 ticks) const void Presenter::SetBackbuffer(int backbuffer_width, int backbuffer_height) { + const bool is_first = m_backbuffer_width == 0 && m_backbuffer_height == 0; + const bool size_changed = + (m_backbuffer_width != backbuffer_width || m_backbuffer_height != backbuffer_height); m_backbuffer_width = backbuffer_width; m_backbuffer_height = backbuffer_height; UpdateDrawRectangle(); + + OnBackbufferSet(size_changed, is_first); } void Presenter::SetBackbuffer(SurfaceInfo info) { + const bool is_first = m_backbuffer_width == 0 && m_backbuffer_height == 0; + const bool size_changed = + (m_backbuffer_width != (int)info.width || m_backbuffer_height != (int)info.height); m_backbuffer_width = info.width; m_backbuffer_height = info.height; m_backbuffer_scale = info.scale; m_backbuffer_format = info.format; if (m_onscreen_ui) m_onscreen_ui->SetScale(info.scale); + + OnBackbufferSet(size_changed, is_first); +} + +void Presenter::OnBackbufferSet(bool size_changed, bool is_first_set) +{ UpdateDrawRectangle(); + + // Automatically update the resolution scale if the window size changed, + // or if the game XFB resolution changed. + if (size_changed && !is_first_set && g_ActiveConfig.iEFBScale == EFB_SCALE_AUTO_INTEGRAL && + m_auto_resolution_scale != AutoIntegralScale()) + { + g_framebuffer_manager->RecreateEFBFramebuffer(); + } + if (size_changed || is_first_set) + { + m_auto_resolution_scale = AutoIntegralScale(); + } } void Presenter::ConfigChanged(u32 changed_bits) diff --git a/Source/Core/VideoCommon/Present.h b/Source/Core/VideoCommon/Present.h index cebd4a332d..3a36bf0913 100644 --- a/Source/Core/VideoCommon/Present.h +++ b/Source/Core/VideoCommon/Present.h @@ -55,6 +55,7 @@ public: void SetSuggestedWindowSize(int width, int height); void SetBackbuffer(int backbuffer_width, int backbuffer_height); void SetBackbuffer(SurfaceInfo info); + void OnBackbufferSet(bool size_changed, bool is_first_set); void UpdateDrawRectangle(); @@ -104,6 +105,8 @@ private: void ProcessFrameDumping(u64 ticks) const; + void OnBackBufferSizeChanged(); + std::tuple CalculateOutputDimensions(int width, int height, bool allow_stretch = true) const; std::tuple ApplyStandardAspectCrop(float width, float height, @@ -132,6 +135,8 @@ private: // Offsets imply black borders (if the window aspect ratio doesn't match the game's one). MathUtil::Rectangle m_target_rectangle = {}; + u32 m_auto_resolution_scale = 1; + RcTcacheEntry m_xfb_entry; MathUtil::Rectangle m_xfb_rect; diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 975b5c0f8d..d9cb9ad0c3 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -289,6 +289,7 @@ void CheckForConfigChanges() const u32 old_game_mod_changes = g_ActiveConfig.graphics_mod_config ? g_ActiveConfig.graphics_mod_config->GetChangeCount() : 0; const bool old_graphics_mods_enabled = g_ActiveConfig.bGraphicMods; + const AspectMode old_aspect_mode = g_ActiveConfig.aspect_mode; const AspectMode old_suggested_aspect_mode = g_ActiveConfig.suggested_aspect_mode; const bool old_widescreen_hack = g_ActiveConfig.bWidescreenHack; const auto old_post_processing_shader = g_ActiveConfig.sPostProcessingShader; @@ -338,6 +339,8 @@ void CheckForConfigChanges() changed_bits |= CONFIG_CHANGE_BIT_BBOX; if (old_efb_scale != g_ActiveConfig.iEFBScale) changed_bits |= CONFIG_CHANGE_BIT_TARGET_SIZE; + if (old_aspect_mode != g_ActiveConfig.aspect_mode) + changed_bits |= CONFIG_CHANGE_BIT_ASPECT_RATIO; if (old_suggested_aspect_mode != g_ActiveConfig.suggested_aspect_mode) changed_bits |= CONFIG_CHANGE_BIT_ASPECT_RATIO; if (old_widescreen_hack != g_ActiveConfig.bWidescreenHack)