From 2b0ab12c4d1e6e2952eedd30dbc1d2993b6d4fa3 Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Sun, 5 Mar 2017 14:52:27 +0100 Subject: [PATCH] Add PostShader option to force 60fps for animated effects --- Core/HLE/sceDisplay.cpp | 10 ++++++++-- GPU/Common/PostShader.cpp | 2 ++ GPU/Common/PostShader.h | 2 ++ assets/shaders/defaultshaders.ini | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index acf25565cc..6aa972ef3a 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -52,6 +52,7 @@ #include "GPU/GPUState.h" #include "GPU/GPUInterface.h" #include "GPU/Common/FramebufferCommon.h" +#include "GPU/Common/PostShader.h" struct FrameBufferState { u32 topaddr; @@ -627,8 +628,13 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { // some work. // But, let's flip at least once every 10 vblanks, to update fps, etc. const bool noRecentFlip = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && numVBlanksSinceFlip >= 10; + // Also let's always flip for animated shaders + const ShaderInfo *shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName); + bool postEffectRequiresFlip = false; + if (shaderInfo) + postEffectRequiresFlip = g_Config.sPostShaderName != "Off" && shaderInfo->requires60fps; const bool fbDirty = gpu->FramebufferDirty(); - if (fbDirty || noRecentFlip) { + if (fbDirty || noRecentFlip || postEffectRequiresFlip) { if (g_Config.iShowFPSCounter && g_Config.iShowFPSCounter < 4) { CalculateFPS(); } @@ -636,7 +642,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { // Setting CORE_NEXTFRAME causes a swap. // Check first though, might've just quit / been paused. const bool fbReallyDirty = gpu->FramebufferReallyDirty(); - if (fbReallyDirty || noRecentFlip) { + if (fbReallyDirty || noRecentFlip || postEffectRequiresFlip) { if (coreState == CORE_RUNNING) { coreState = CORE_NEXTFRAME; gpu->CopyDisplayToOutput(); diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index fdba037f28..57874a7f3c 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -42,6 +42,7 @@ void LoadPostShaderInfo(std::vector directories) { off.section = "Off"; off.outputResolution = false; off.isUpscalingFilter = false; + off.requires60fps = false; shaderInfo.push_back(off); for (size_t d = 0; d < directories.size(); d++) { @@ -86,6 +87,7 @@ void LoadPostShaderInfo(std::vector directories) { info.vertexShaderFile = path + "/" + temp; section.Get("OutputResolution", &info.outputResolution, false); section.Get("Upscaling", &info.isUpscalingFilter, false); + section.Get("60fps", &info.requires60fps, false); // Let's ignore shaders we can't support. TODO: Not a very good check if (gl_extensions.IsGLES && !gl_extensions.GLES3) { diff --git a/GPU/Common/PostShader.h b/GPU/Common/PostShader.h index 6a87f2745b..d743ba0bc7 100644 --- a/GPU/Common/PostShader.h +++ b/GPU/Common/PostShader.h @@ -36,6 +36,8 @@ struct ShaderInfo { bool outputResolution; // Use x1 rendering res + nearest screen scaling filter bool isUpscalingFilter; + // Force constant/max refresh for animated filters + bool requires60fps; // TODO: Add support for all kinds of fun options like mapping the depth buffer, // SRGB texture reads, multiple shaders chained, etc. diff --git a/assets/shaders/defaultshaders.ini b/assets/shaders/defaultshaders.ini index 7f8d5338d2..2d8e7bd735 100644 --- a/assets/shaders/defaultshaders.ini +++ b/assets/shaders/defaultshaders.ini @@ -9,6 +9,7 @@ Name=CRT Scanlines Author=KillaMaaki Fragment=crt.fsh Vertex=fxaa.vsh +60fps=True [Natural] Name=Natural Colors Fragment=natural.fsh