diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-06-02 13:11:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-06-02 13:11:39 +0300 |
commit | cecda64e2ead502a052f9bea5ffde39e4a46bf90 (patch) | |
tree | 0473548813e5823312a7a4381b75b7d1324e8ba2 /intern/opencolorio | |
parent | bdda53fdb29d9f015df2db66a0cda98b0c19e1ff (diff) |
GPU: ShaderInterface: Refactor to setup all uniform at creation time
This remove the complexity of queriying the locations at runtime and
allows for more performance and upfront binding specifications.
The benefit of doing everything at creation time is that we can assign binding
points in a predictable order which is going to be somewhat the same for
every similar shader.
This also rewrite GPU_vertformat_from_shader to not use shaderface.
This is to keep the shaderface simple. If it becomes necessary to not query
the shader after creation (i.e: vulkan?) we could just create the vert
format in advance at compilation for PyGPU shaders.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D7879
Diffstat (limited to 'intern/opencolorio')
-rw-r--r-- | intern/opencolorio/ocio_impl_glsl.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index df6adc8f34b..87769a647f6 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -263,11 +263,6 @@ static void updateGLSLShader(OCIO_GLSLShader *shader, shader->curve_mapping_loc = glGetUniformLocation(shader->program, "curve_mapping"); glUseProgram(shader->program); - /* Set texture bind point uniform once. This is saved by the shader. */ - glUniform1i(glGetUniformLocation(shader->program, "image_texture"), 0); - glUniform1i(glGetUniformLocation(shader->program, "lut3d_texture"), 2); - glUniform1i(glGetUniformLocation(shader->program, "lut3d_display_texture"), 3); - glUniform1i(glGetUniformLocation(shader->program, "curve_mapping_texture"), 4); /* Set UBO binding location. */ GLuint index = glGetUniformBlockIndex(shader->program, "OCIO_GLSLCurveMappingParameters"); @@ -276,6 +271,12 @@ static void updateGLSLShader(OCIO_GLSLShader *shader, /* TODO(fclem) Remove this. Make caller always assume viewport space and * specify texco via vertex attribs. */ shader->interface = GPU_shaderinterface_create(shader->program); + + /* Set texture bind point uniform once. This is saved by the shader. */ + glUniform1i(glGetUniformLocation(shader->program, "image_texture"), 0); + glUniform1i(glGetUniformLocation(shader->program, "lut3d_texture"), 2); + glUniform1i(glGetUniformLocation(shader->program, "lut3d_display_texture"), 3); + glUniform1i(glGetUniformLocation(shader->program, "curve_mapping_texture"), 4); } shader->cacheId = cache_id; |