diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 382784b502..3fac62bd73 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -33,9 +33,12 @@ void SetPSConstant4fvByName(const char * name, unsigned int offset, const float { if (tmp.shader.UniformLocations[a] == -1) return; + else if (tmp.shader.UniformSize[a] <= offset) + return; else { - glUniform4fv(tmp.shader.UniformLocations[a] + offset, count, f); + unsigned int maxcount= tmp.shader.UniformSize[a]-offset; + glUniform4fv(tmp.shader.UniformLocations[a] + offset, std::min(count, maxcount), f); return; } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index d7cafb49ca..95c5c3f46d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -78,17 +78,35 @@ void SHADER::SetProgramVariables() glUniformBlockBinding(glprogid, VSBlock_id, 2); } - // We cache our uniform locations for now - // Once we move up to a newer version of GLSL, ~1.30 - // We can remove this + // UBO workaround + for (int a = 0; a < NUM_UNIFORMS; ++a) + { + UniformLocations[a] = glGetUniformLocation(glprogid, UniformNames[a]); + UniformSize[a] = 0; + if(g_ActiveConfig.backend_info.bSupportsGLSLUBO) + break; + } + if(!g_ActiveConfig.backend_info.bSupportsGLSLUBO) + { + int max_uniforms = 0; + char name[50]; + int size; + + glGetProgramiv(glprogid, GL_ACTIVE_UNIFORMS, &max_uniforms); + for(int i=0; i