From 406fed791429f0b23643984f56059d3af1616773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 10 Sep 2020 23:47:54 +0200 Subject: [PATCH] Add option for the clear-fb-on-first-use speedhack. See #13295 --- Core/Config.cpp | 2 ++ Core/Config.h | 1 + GPU/Common/FramebufferManagerCommon.cpp | 6 +----- GPU/Common/FramebufferManagerCommon.h | 1 - UI/GameSettingsScreen.cpp | 9 +++++++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 3164c9af9b..7e22329a73 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -818,6 +818,8 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, true, false), ConfigSetting("RenderDuplicateFrames", &g_Config.bRenderDuplicateFrames, false, true, true), + ConfigSetting("ClearFramebuffersOnFirstUseHack", &g_Config.bClearFramebuffersOnFirstUseHack, false, true, true), + ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 3072efdbc3..f55a060dad 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -165,6 +165,7 @@ public: int iFrameSkipType; int iUnthrottleMode; // See UnthrottleMode in ConfigValues.h. bool bAutoFrameSkip; + bool bClearFramebuffersOnFirstUseHack; bool bEnableCardboardVR; // Cardboard Master Switch int iCardboardScreenSize; // Screen Size (in %) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 90f06fa10e..bd36e95532 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -44,10 +44,6 @@ FramebufferManagerCommon::FramebufferManagerCommon(Draw::DrawContext *draw) : draw_(draw), displayFormat_(GE_FORMAT_565) { presentation_ = new PresentationCommon(draw); - - // See comment from where it's used below. - // As for the use of IsGLES, just the way it was. Scary to change it. - clearFramebufferOnFirstUseHack_ = gl_extensions.IsGLES; } FramebufferManagerCommon::~FramebufferManagerCommon() { @@ -536,7 +532,7 @@ void FramebufferManagerCommon::NotifyRenderFramebufferSwitched(VirtualFramebuffe if (useBufferedRendering_) { if (vfb->fbo) { shaderManager_->DirtyLastShader(); - if (clearFramebufferOnFirstUseHack_) { + if (g_Config.bClearFramebuffersOnFirstUseHack) { // HACK: Some tiled mobile GPUs benefit IMMENSELY from clearing an FBO before rendering // to it (or in Vulkan, clear during framebuffer load). This is a hack to force this // the first time a framebuffer is bound for rendering in a frame. diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index 66954c511c..5738f930e8 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -396,7 +396,6 @@ protected: std::vector bvfbs_; // blitting framebuffers (for download) bool gameUsesSequentialCopies_ = false; - bool clearFramebufferOnFirstUseHack_ = false; // Sampled in BeginFrame for safety. float renderWidth_ = 0.0f; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0e248c2981..60d2757f41 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -415,6 +415,15 @@ void GameSettingsScreen::CreateViews() { return !g_Config.bSoftwareRendering && g_Config.bHardwareTransform; }); + CheckBox *clearHack = graphicsSettings->Add(new CheckBox(&g_Config.bClearFramebuffersOnFirstUseHack, gr->T("Clear Speedhack", "Clear framebuffers on first use (speedhack)"))); + clearHack->OnClick.Add([=](EventParams &e) { + settingInfo_->Show(gr->T("ClearSpeedhack Tip", "Sometimes faster (mostly on mobile devices), may cause glitches"), e.v); + return UI::EVENT_CONTINUE; + }); + clearHack->SetEnabledFunc([] { + return !g_Config.bSoftwareRendering; + }); + CheckBox *texBackoff = graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gr->T("Lazy texture caching", "Lazy texture caching (speedup)"))); texBackoff->SetDisabledPtr(&g_Config.bSoftwareRendering);