mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
OGL: Fix abstract pipelines on drivers without binding layout support
This commit is contained in:
@ -98,17 +98,18 @@ static std::string GetGLSLVersionString()
|
|||||||
|
|
||||||
void SHADER::SetProgramVariables()
|
void SHADER::SetProgramVariables()
|
||||||
{
|
{
|
||||||
// Bind UBO and texture samplers
|
if (g_ActiveConfig.backend_info.bSupportsBindingLayout)
|
||||||
if (!g_ActiveConfig.backend_info.bSupportsBindingLayout)
|
return;
|
||||||
{
|
|
||||||
// glsl shader must be bind to set samplers if we don't support binding layout
|
|
||||||
Bind();
|
|
||||||
|
|
||||||
|
// To set uniform blocks/uniforms, the program must be active. We restore the
|
||||||
|
// current binding at the end of this method to maintain the invariant.
|
||||||
|
glUseProgram(glprogid);
|
||||||
|
|
||||||
|
// Bind UBO and texture samplers
|
||||||
GLint PSBlock_id = glGetUniformBlockIndex(glprogid, "PSBlock");
|
GLint PSBlock_id = glGetUniformBlockIndex(glprogid, "PSBlock");
|
||||||
GLint VSBlock_id = glGetUniformBlockIndex(glprogid, "VSBlock");
|
GLint VSBlock_id = glGetUniformBlockIndex(glprogid, "VSBlock");
|
||||||
GLint GSBlock_id = glGetUniformBlockIndex(glprogid, "GSBlock");
|
GLint GSBlock_id = glGetUniformBlockIndex(glprogid, "GSBlock");
|
||||||
GLint UBERBlock_id = glGetUniformBlockIndex(glprogid, "UBERBlock");
|
GLint UBERBlock_id = glGetUniformBlockIndex(glprogid, "UBERBlock");
|
||||||
|
|
||||||
if (PSBlock_id != -1)
|
if (PSBlock_id != -1)
|
||||||
glUniformBlockBinding(glprogid, PSBlock_id, 1);
|
glUniformBlockBinding(glprogid, PSBlock_id, 1);
|
||||||
if (VSBlock_id != -1)
|
if (VSBlock_id != -1)
|
||||||
@ -119,7 +120,7 @@ void SHADER::SetProgramVariables()
|
|||||||
glUniformBlockBinding(glprogid, UBERBlock_id, 4);
|
glUniformBlockBinding(glprogid, UBERBlock_id, 4);
|
||||||
|
|
||||||
// Bind Texture Samplers
|
// Bind Texture Samplers
|
||||||
for (int a = 0; a <= 9; ++a)
|
for (int a = 0; a < 10; ++a)
|
||||||
{
|
{
|
||||||
std::string name = StringFromFormat(a < 8 ? "samp[%d]" : "samp%d", a);
|
std::string name = StringFromFormat(a < 8 ? "samp[%d]" : "samp%d", a);
|
||||||
|
|
||||||
@ -128,7 +129,9 @@ void SHADER::SetProgramVariables()
|
|||||||
if (loc != -1)
|
if (loc != -1)
|
||||||
glUniform1i(loc, a);
|
glUniform1i(loc, a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Restore previous program binding.
|
||||||
|
glUseProgram(CurrentProgram);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHADER::SetProgramBindings(bool is_compute)
|
void SHADER::SetProgramBindings(bool is_compute)
|
||||||
@ -956,6 +959,9 @@ const PipelineProgram* ProgramShaderCache::GetPipelineProgram(const OGLShader* v
|
|||||||
return iter->second.get();
|
return iter->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set program variables on the shader which will be returned.
|
||||||
|
// This is only needed for drivers which don't support binding layout.
|
||||||
|
prog->shader.SetProgramVariables();
|
||||||
auto ip = pipelineprograms.emplace(key, std::move(prog));
|
auto ip = pipelineprograms.emplace(key, std::move(prog));
|
||||||
return ip.first->second.get();
|
return ip.first->second.get();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user