Fix bug where we'd reload the post shader information every frame. Fixes #9410

This commit is contained in:
Henrik Rydgard 2017-03-11 12:25:43 +01:00
parent e68ea3bc3a
commit 9bb81a24c0
8 changed files with 13 additions and 9 deletions

View File

@ -628,11 +628,11 @@ 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);
// Also let's always flip for animated shaders.
const ShaderInfo *shaderInfo = g_Config.sPostShaderName == "Off" ? nullptr : GetPostShaderInfo(g_Config.sPostShaderName);
bool postEffectRequiresFlip = false;
if (shaderInfo && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE)
postEffectRequiresFlip = g_Config.sPostShaderName != "Off" && shaderInfo->requires60fps;
postEffectRequiresFlip = shaderInfo->requires60fps;
const bool fbDirty = gpu->FramebufferDirty();
if (fbDirty || noRecentFlip || postEffectRequiresFlip) {
if (g_Config.iShowFPSCounter && g_Config.iShowFPSCounter < 4) {

View File

@ -109,7 +109,7 @@ void LoadPostShaderInfo(std::vector<std::string> directories) {
}
// Scans the directories for shader ini files and collects info about all the shaders found.
void LoadAllPostShaderInfo() {
void ReloadAllPostShaderInfo() {
std::vector<std::string> directories;
directories.push_back("shaders");
directories.push_back(g_Config.memStickDirectory + "PSP/shaders");
@ -117,15 +117,13 @@ void LoadAllPostShaderInfo() {
}
const ShaderInfo *GetPostShaderInfo(std::string name) {
LoadAllPostShaderInfo();
for (size_t i = 0; i < shaderInfo.size(); i++) {
if (shaderInfo[i].section == name)
return &shaderInfo[i];
}
return 0;
return nullptr;
}
const std::vector<ShaderInfo> &GetAllPostShaderInfo() {
LoadAllPostShaderInfo();
return shaderInfo;
}

View File

@ -47,6 +47,7 @@ struct ShaderInfo {
}
};
const ShaderInfo *GetPostShaderInfo(std::string name);
void ReloadAllPostShaderInfo();
const ShaderInfo *GetPostShaderInfo(std::string name);
const std::vector<ShaderInfo> &GetAllPostShaderInfo();

View File

@ -236,7 +236,7 @@ void FramebufferManagerD3D11::CompilePostShader() {
postInputLayout_ = nullptr;
}
const ShaderInfo *shaderInfo = 0;
const ShaderInfo *shaderInfo = nullptr;
if (g_Config.sPostShaderName == "Off") {
usePostShader_ = false;
return;
@ -244,6 +244,7 @@ void FramebufferManagerD3D11::CompilePostShader() {
usePostShader_ = false;
ReloadAllPostShaderInfo();
shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
if (shaderInfo) {
postShaderAtOutputResolution_ = shaderInfo->outputResolution;

View File

@ -132,6 +132,7 @@ void FramebufferManagerGLES::CompilePostShader() {
SetNumExtraFBOs(0);
const ShaderInfo *shaderInfo = 0;
if (g_Config.sPostShaderName != "Off") {
ReloadAllPostShaderInfo();
shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
}

View File

@ -1045,6 +1045,7 @@ void FramebufferManagerVulkan::EndFrame() {
// Check if postprocessing shader is doing upscaling as it requires native resolution
const ShaderInfo *shaderInfo = 0;
if (g_Config.sPostShaderName != "Off") {
ReloadAllPostShaderInfo();
shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
}

View File

@ -286,6 +286,7 @@ UI::EventReturn PromptScreen::OnNo(UI::EventParams &e) {
PostProcScreen::PostProcScreen(const std::string &title) : ListPopupScreen(title) {
I18NCategory *ps = GetI18NCategory("PostShaders");
ReloadAllPostShaderInfo();
shaders_ = GetAllPostShaderInfo();
std::vector<std::string> items;
int selected = -1;

View File

@ -174,6 +174,7 @@ namespace MainWindow {
RemoveMenu(optionsMenu, SUBMENU_CUSTOM_SHADERS, MF_BYPOSITION);
InsertMenu(optionsMenu, SUBMENU_CUSTOM_SHADERS, MF_POPUP | MF_STRING | MF_BYPOSITION, (UINT_PTR)shaderMenu, key.c_str());
ReloadAllPostShaderInfo();
std::vector<ShaderInfo> info = GetAllPostShaderInfo();
availableShaders.clear();