diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 12e692b24..0473d878a 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -429,6 +429,7 @@ bool HostInterface::LoadState(const char* filename) System::ResetPerformanceCounters(); System::ResetThrottler(); + OnDisplayInvalidated(); return true; } @@ -463,6 +464,8 @@ void HostInterface::OnSystemDestroyed() {} void HostInterface::OnSystemPerformanceCountersUpdated() {} +void HostInterface::OnDisplayInvalidated() {} + void HostInterface::OnSystemStateSaved(bool global, s32 slot) {} void HostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, @@ -817,6 +820,7 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings) g_settings.runahead_frames != old_settings.runahead_frames) { g_gpu->UpdateSettings(); + OnDisplayInvalidated(); } if (g_settings.gpu_widescreen_hack != old_settings.gpu_widescreen_hack || @@ -906,16 +910,14 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings) if (g_settings.multitap_mode != old_settings.multitap_mode) System::UpdateMultitaps(); - if (m_display) + if (m_display && g_settings.display_linear_filtering != old_settings.display_linear_filtering || + g_settings.display_integer_scaling != old_settings.display_integer_scaling || + g_settings.display_stretch != old_settings.display_stretch) { - if (g_settings.display_linear_filtering != old_settings.display_linear_filtering) - m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering); - - if (g_settings.display_integer_scaling != old_settings.display_integer_scaling) - m_display->SetDisplayIntegerScaling(g_settings.display_integer_scaling); - - if (g_settings.display_stretch != old_settings.display_stretch) - m_display->SetDisplayStretch(g_settings.display_stretch); + m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering); + m_display->SetDisplayIntegerScaling(g_settings.display_integer_scaling); + m_display->SetDisplayStretch(g_settings.display_stretch); + OnDisplayInvalidated(); } } @@ -1100,6 +1102,7 @@ void HostInterface::ToggleSoftwareRendering() AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "Switching to %s renderer..."), Settings::GetRendererDisplayName(new_renderer)); System::RecreateGPU(new_renderer); + OnDisplayInvalidated(); } void HostInterface::ModifyResolutionScale(s32 increment) @@ -1117,6 +1120,7 @@ void HostInterface::ModifyResolutionScale(s32 increment) g_gpu->UpdateSettings(); g_gpu->ResetGraphicsAPIState(); System::ClearMemorySaveStates(); + OnDisplayInvalidated(); } } @@ -1181,6 +1185,7 @@ void HostInterface::RecreateSystem() System::ResetPerformanceCounters(); System::ResetThrottler(); + OnDisplayInvalidated(); } void HostInterface::SetMouseMode(bool relative, bool hide_cursor) {} diff --git a/src/core/host_interface.h b/src/core/host_interface.h index 14bacc247..0b03a90f8 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -150,6 +150,9 @@ public: const std::string& game_title); virtual void OnSystemPerformanceCountersUpdated(); + /// Called when the display is invalidated (e.g. a state is loaded). + virtual void OnDisplayInvalidated(); + protected: virtual bool AcquireHostDisplay() = 0; virtual void ReleaseHostDisplay() = 0; diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index e7eec3092..c74c79435 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -1322,8 +1322,6 @@ void QtHostInterface::loadState(const QString& filename) emit emulationStarting(); LoadState(filename.toStdString().c_str()); - if (System::IsValid()) - renderDisplay(); } void QtHostInterface::loadState(bool global, qint32 slot) @@ -1335,8 +1333,6 @@ void QtHostInterface::loadState(bool global, qint32 slot) } LoadState(global, slot); - if (System::IsValid()) - renderDisplay(); } void QtHostInterface::saveState(const QString& filename, bool block_until_done /* = false */) @@ -1533,6 +1529,12 @@ void QtHostInterface::OnAchievementsRefreshed() Cheevos::GetMaximumPointsForGame()); #endif } + +void QtHostInterface::OnDisplayInvalidated() +{ + renderDisplay(); +} + void QtHostInterface::doBackgroundControllerPoll() { PollAndUpdate(); diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index df989ba67..a18d8fb63 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -185,6 +185,7 @@ public Q_SLOTS: void requestRenderWindowScale(qreal scale); void executeOnEmulationThread(std::function callback, bool wait = false); void OnAchievementsRefreshed() override; + void OnDisplayInvalidated() override; private Q_SLOTS: void doStopThread();