diff options
| author | Jules Blok <jules.blok@gmail.com> | 2015-01-25 23:08:49 +0100 |
|---|---|---|
| committer | Jules Blok <jules.blok@gmail.com> | 2015-01-25 23:08:49 +0100 |
| commit | 5c4ee2f71e2e1c80ba2bf829751f1202f6e65ee9 (patch) | |
| tree | d0995aeae829c25af97d57d88dd1f1b14810cbfb /Source/Core | |
| parent | fc46d460f987fc718bc07add95c49c2425c50159 (diff) | |
PostProcessing: Move default pixel shader to PostProcessingShaderConfiguration.
Reduces code complexity and fixes a bug where the shader is not properly invalidated.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/PostProcessing.cpp | 14 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PostProcessing.cpp | 23 |
2 files changed, 19 insertions, 18 deletions
diff --git a/Source/Core/VideoBackends/OGL/PostProcessing.cpp b/Source/Core/VideoBackends/OGL/PostProcessing.cpp index 3fa6f26de9..b03dc940be 100644 --- a/Source/Core/VideoBackends/OGL/PostProcessing.cpp +++ b/Source/Core/VideoBackends/OGL/PostProcessing.cpp @@ -36,8 +36,6 @@ static const char s_vertex_shader[] = " uv0 = rawpos * src_rect.zw + src_rect.xy;\n" "}\n"; -static const char s_default_shader[] = "void main() { SetOutput(Sample()); }\n"; - OpenGLPostProcessing::OpenGLPostProcessing() : m_initialized(false) { @@ -171,13 +169,7 @@ void OpenGLPostProcessing::ApplyShader() m_uniform_bindings.clear(); // load shader code - std::string code = ""; - if (g_ActiveConfig.sPostProcessingShader != "") - code = m_config.LoadShader(); - - if (code == "") - code = s_default_shader; - + std::string code = m_config.LoadShader(); code = LoadShaderOptions(code); const char* vertex_shader = s_vertex_shader; @@ -189,8 +181,8 @@ void OpenGLPostProcessing::ApplyShader() if (!ProgramShaderCache::CompileShader(m_shader, vertex_shader, code.c_str())) { ERROR_LOG(VIDEO, "Failed to compile post-processing shader %s", m_config.GetShader().c_str()); - - code = LoadShaderOptions(s_default_shader); + g_ActiveConfig.sPostProcessingShader.clear(); + code = m_config.LoadShader(); ProgramShaderCache::CompileShader(m_shader, vertex_shader, code.c_str()); } diff --git a/Source/Core/VideoCommon/PostProcessing.cpp b/Source/Core/VideoCommon/PostProcessing.cpp index c27b0f89fc..c299d41b15 100644 --- a/Source/Core/VideoCommon/PostProcessing.cpp +++ b/Source/Core/VideoCommon/PostProcessing.cpp @@ -13,6 +13,8 @@ #include "VideoCommon/VideoConfig.h" +static const char s_default_shader[] = "void main() { SetOutput(Sample()); }\n"; + PostProcessingShaderImplementation::PostProcessingShaderImplementation() { m_timer.Start(); @@ -36,16 +38,23 @@ std::string PostProcessingShaderConfiguration::LoadShader(std::string shader) std::string code; std::string path = File::GetUserPath(D_SHADERS_IDX) + sub_dir + shader + ".glsl"; - if (!File::Exists(path)) + if (shader == "") { - // Fallback to shared user dir - path = File::GetSysDirectory() + SHADERS_DIR DIR_SEP + sub_dir + shader + ".glsl"; + code = s_default_shader; } - - if (!File::ReadFileToString(path, code)) + else { - ERROR_LOG(VIDEO, "Post-processing shader not found: %s", path.c_str()); - return ""; + if (!File::Exists(path)) + { + // Fallback to shared user dir + path = File::GetSysDirectory() + SHADERS_DIR DIR_SEP + sub_dir + shader + ".glsl"; + } + + if (!File::ReadFileToString(path, code)) + { + ERROR_LOG(VIDEO, "Post-processing shader not found: %s", path.c_str()); + code = s_default_shader; + } } LoadOptions(code); |
