ogl: fix ubo workaround
This commit is contained in:
parent
1469342f83
commit
c9e13f6b7a
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<max_uniforms; i++)
|
||||
{
|
||||
glGetActiveUniform(glprogid, i, sizeof(name), NULL, &size, NULL, name);
|
||||
for (int a = 0; a < NUM_UNIFORMS; ++a)
|
||||
{
|
||||
if(strstr(name, UniformNames[a]))
|
||||
{
|
||||
UniformSize[a] = size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// (Sonicadvance): For some reason this fails on my hardware
|
||||
//glGetUniformIndices(glprogid, NUM_UNIFORMS, UniformNames, UniformLocations);
|
||||
// Got to do it this crappy way.
|
||||
UniformLocations[0] = glGetUniformLocation(glprogid, UniformNames[0]);
|
||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
for (int a = 1; a < NUM_UNIFORMS; ++a)
|
||||
UniformLocations[a] = glGetUniformLocation(glprogid, UniformNames[a]);
|
||||
|
||||
// Bind Texture Sampler
|
||||
for (int a = 0; a <= 9; ++a)
|
||||
|
|
|
@ -56,6 +56,7 @@ struct SHADER
|
|||
|
||||
std::string strvprog, strpprog;
|
||||
GLint UniformLocations[NUM_UNIFORMS];
|
||||
u32 UniformSize[NUM_UNIFORMS];
|
||||
|
||||
void SetProgramVariables();
|
||||
void SetProgramBindings();
|
||||
|
|
|
@ -33,9 +33,12 @@ void SetVSConstant4fvByName(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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue