OpenGL: use ShaderInterface to look up uniforms

These were the last few glGetUniformLocation calls in source/blender.

The new system gets uniform information once when a shader is created, then uses this cached info every time after that.
This commit is contained in:
Mike Erwin 2017-04-13 18:37:26 -04:00
parent 532532afc7
commit 26f25b1b27
1 changed files with 6 additions and 6 deletions

View File

@ -467,21 +467,21 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
return NULL;
}
shader->interface = ShaderInterface_create(shader->program);
#ifdef WITH_OPENSUBDIV
/* TODO(sergey): Find a better place for this. */
if (use_opensubdiv && GLEW_VERSION_4_1) {
glProgramUniform1i(shader->program,
glGetUniformLocation(shader->program, "FVarDataOffsetBuffer"),
ShaderInterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location,
30); /* GL_TEXTURE30 */
glProgramUniform1i(shader->program,
glGetUniformLocation(shader->program, "FVarDataBuffer"),
ShaderInterface_uniform(shader->interface, "FVarDataBuffer")->location,
31); /* GL_TEXTURE31 */
}
#endif
shader->interface = ShaderInterface_create(shader->program);
return shader;
}
@ -523,8 +523,8 @@ void GPU_shader_free(GPUShader *shader)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
{
BLI_assert(shader && shader->program);
return glGetUniformLocation(shader->program, name);
const ShaderInput *uniform = ShaderInterface_uniform(shader->interface, name);
return uniform ? uniform->location : -1;
}
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)