diff options
author | Mike Erwin <significant.bit@gmail.com> | 2017-04-14 01:37:26 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2017-04-14 01:37:26 +0300 |
commit | 26f25b1b27bd850b0e6cd1bfc045fcfd41f1ba3b (patch) | |
tree | a9d4b10e636b688557d823f523cefe63491791a7 /source/blender/gpu/intern/gpu_shader.c | |
parent | 532532afc7316e05e1603529a84f6c3ab8ee32d3 (diff) |
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.
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index fa63dff1458..2a0e434537f 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -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) |