From d3850965993c521c09362f140f02067d8de19aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 29 Jan 2020 10:16:03 +0100 Subject: [PATCH] Add option to improve frame pacing through duplicate frames if framerate is below 60hz. Should help #9736, and fixes #12325. --- Core/Config.cpp | 1 + Core/Config.h | 1 + Core/HLE/sceDisplay.cpp | 4 +++- UI/GameSettingsScreen.cpp | 5 +++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 9d04db3ba5c0..b20b7f62e6fd 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -776,6 +776,7 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false), ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, true, false), + ConfigSetting("RenderDuplicateFrames", &g_Config.bRenderDuplicateFrames, false, true, true), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 67a07597f4d8..d8a52cccde9d 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -207,6 +207,7 @@ struct Config { bool bGfxDebugOutput; bool bGfxDebugSplitSubmit; int iInflightFrames; + bool bRenderDuplicateFrames; // Sound bool bEnableSound; diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 2871be814019..09e6a8f98530 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -754,9 +754,11 @@ void __DisplayFlip(int cyclesLate) { // Also let's always flip for animated shaders. const ShaderInfo *shaderInfo = g_Config.sPostShaderName == "Off" ? nullptr : GetPostShaderInfo(g_Config.sPostShaderName); bool postEffectRequiresFlip = false; + // postEffectRequiresFlip is not compatible with frameskip unthrottling, see #12325. if (shaderInfo && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) - postEffectRequiresFlip = shaderInfo->requires60fps; + postEffectRequiresFlip = (shaderInfo->requires60fps || g_Config.bRenderDuplicateFrames) && !(g_Config.bFrameSkipUnthrottle && !FrameTimingThrottled()); const bool fbDirty = gpu->FramebufferDirty(); + if (fbDirty || noRecentFlip || postEffectRequiresFlip) { int frameSleepPos = frameTimeHistoryPos; CalculateFPS(); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index ca2ff3a606f3..10801c161054 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -343,6 +343,11 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_CONTINUE; }); #endif + CheckBox *frameDuplication = graphicsSettings->Add(new CheckBox(&g_Config.bRenderDuplicateFrames, gr->T("Render duplicate frames to 60hz"))); + frameDuplication->OnClick.Add([=](EventParams &e) { + settingInfo_->Show(gr->T("RenderDuplicateFrames Tip", "Can make framerate smoother in games that run at lower framerates"), e.v); + return UI::EVENT_CONTINUE; + }); if (GetGPUBackend() == GPUBackend::VULKAN || GetGPUBackend() == GPUBackend::OPENGL) { static const char *bufferOptions[] = { "No buffer", "Up to 1", "Up to 2" };