mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
FullscreenUI: Fix incorrect vsync state on unpause
This commit is contained in:
parent
c2f4b7e7b8
commit
6386004b2c
|
@ -2192,11 +2192,10 @@ void System::UpdateSpeedLimiterState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool is_non_standard_speed = (std::abs(target_speed - 1.0f) > 0.05f);
|
const bool is_non_standard_speed = IsRunningAtNonStandardSpeed();
|
||||||
const bool audio_sync_enabled =
|
const bool audio_sync_enabled =
|
||||||
!IsRunning() || (m_throttler_enabled && g_settings.audio_sync_enabled && !is_non_standard_speed);
|
!IsRunning() || (m_throttler_enabled && g_settings.audio_sync_enabled && !is_non_standard_speed);
|
||||||
const bool video_sync_enabled =
|
const bool video_sync_enabled = ShouldUseVSync();
|
||||||
!IsRunning() || (m_throttler_enabled && g_settings.video_sync_enabled && !is_non_standard_speed);
|
|
||||||
const float max_display_fps = (!IsRunning() || m_throttler_enabled) ? 0.0f : g_settings.display_max_fps;
|
const float max_display_fps = (!IsRunning() || m_throttler_enabled) ? 0.0f : g_settings.display_max_fps;
|
||||||
Log_InfoPrintf("Target speed: %f%%", target_speed * 100.0f);
|
Log_InfoPrintf("Target speed: %f%%", target_speed * 100.0f);
|
||||||
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
|
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
|
||||||
|
@ -2241,6 +2240,11 @@ void System::UpdateSpeedLimiterState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool System::ShouldUseVSync()
|
||||||
|
{
|
||||||
|
return (!IsRunning() || (m_throttler_enabled && g_settings.video_sync_enabled && !IsRunningAtNonStandardSpeed()));
|
||||||
|
}
|
||||||
|
|
||||||
bool System::IsFastForwardEnabled()
|
bool System::IsFastForwardEnabled()
|
||||||
{
|
{
|
||||||
return m_fast_forward_enabled;
|
return m_fast_forward_enabled;
|
||||||
|
|
|
@ -400,6 +400,9 @@ void ToggleWidescreen();
|
||||||
/// Returns true if fast forwarding or slow motion is currently active.
|
/// Returns true if fast forwarding or slow motion is currently active.
|
||||||
bool IsRunningAtNonStandardSpeed();
|
bool IsRunningAtNonStandardSpeed();
|
||||||
|
|
||||||
|
/// Returns true if vsync should be used.
|
||||||
|
bool ShouldUseVSync();
|
||||||
|
|
||||||
/// Quick switch between software and hardware rendering.
|
/// Quick switch between software and hardware rendering.
|
||||||
void ToggleSoftwareRendering();
|
void ToggleSoftwareRendering();
|
||||||
|
|
||||||
|
|
|
@ -870,12 +870,18 @@ bool EmuThread::acquireHostDisplay(HostDisplay::RenderAPI api)
|
||||||
|
|
||||||
m_is_exclusive_fullscreen = g_host_display->IsFullscreen();
|
m_is_exclusive_fullscreen = g_host_display->IsFullscreen();
|
||||||
|
|
||||||
if (m_run_fullscreen_ui && !FullscreenUI::Initialize())
|
if (m_run_fullscreen_ui)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to initialize fullscreen UI");
|
if (!FullscreenUI::Initialize())
|
||||||
releaseHostDisplay();
|
{
|
||||||
m_run_fullscreen_ui = false;
|
Log_ErrorPrint("Failed to initialize fullscreen UI");
|
||||||
return false;
|
releaseHostDisplay();
|
||||||
|
m_run_fullscreen_ui = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start with vsync on
|
||||||
|
g_host_display->SetVSync(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -166,7 +166,6 @@ static std::string TimeToPrintableString(time_t t);
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Main
|
// Main
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
static void UpdateForcedVsync(bool should_force);
|
|
||||||
static void PauseForMenuOpen();
|
static void PauseForMenuOpen();
|
||||||
static void ClosePauseMenu();
|
static void ClosePauseMenu();
|
||||||
static void OpenPauseSubMenu(PauseSubMenu submenu);
|
static void OpenPauseSubMenu(PauseSubMenu submenu);
|
||||||
|
@ -440,10 +439,6 @@ bool FullscreenUI::Initialize()
|
||||||
if (!System::IsValid())
|
if (!System::IsValid())
|
||||||
SwitchToLanding();
|
SwitchToLanding();
|
||||||
|
|
||||||
// force vsync on so we don't run at thousands of fps
|
|
||||||
// Initialize is called on the GS thread, so we can access the display directly.
|
|
||||||
UpdateForcedVsync(System::GetState() != System::State::Running);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,13 +453,6 @@ bool FullscreenUI::HasActiveWindow()
|
||||||
ImGuiFullscreen::IsChoiceDialogOpen() || ImGuiFullscreen::IsFileSelectorOpen());
|
ImGuiFullscreen::IsChoiceDialogOpen() || ImGuiFullscreen::IsFileSelectorOpen());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::UpdateForcedVsync(bool should_force)
|
|
||||||
{
|
|
||||||
// force vsync on so we don't run at thousands of fps
|
|
||||||
// toss it through regardless of the mode, because options can change it
|
|
||||||
g_host_display->SetVSync((should_force && !g_settings.video_sync_enabled) ? true : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FullscreenUI::OnSystemStarted()
|
void FullscreenUI::OnSystemStarted()
|
||||||
{
|
{
|
||||||
if (!IsInitialized())
|
if (!IsInitialized())
|
||||||
|
@ -479,7 +467,7 @@ void FullscreenUI::OnSystemPaused()
|
||||||
if (!IsInitialized())
|
if (!IsInitialized())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateForcedVsync(true);
|
g_host_display->SetVSync(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::OnSystemResumed()
|
void FullscreenUI::OnSystemResumed()
|
||||||
|
@ -487,7 +475,7 @@ void FullscreenUI::OnSystemResumed()
|
||||||
if (!IsInitialized())
|
if (!IsInitialized())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateForcedVsync(false);
|
g_host_display->SetVSync(System::ShouldUseVSync());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::OnSystemDestroyed()
|
void FullscreenUI::OnSystemDestroyed()
|
||||||
|
@ -495,9 +483,9 @@ void FullscreenUI::OnSystemDestroyed()
|
||||||
if (!IsInitialized())
|
if (!IsInitialized())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
g_host_display->SetVSync(true);
|
||||||
s_pause_menu_was_open = false;
|
s_pause_menu_was_open = false;
|
||||||
SwitchToLanding();
|
SwitchToLanding();
|
||||||
UpdateForcedVsync(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::OnRunningGameChanged()
|
void FullscreenUI::OnRunningGameChanged()
|
||||||
|
|
Loading…
Reference in a new issue