diff options
author | Samuel Pitoiset <[email protected]> | 2017-05-11 12:31:27 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-05-11 21:08:32 +0200 |
commit | 4ad5fa617c1d8e18b06d94e8c44e55b268631604 (patch) | |
tree | 821bb80004a2f1308e5db7325cd805ac4b780e5d /src/compiler/glsl | |
parent | a29810e27ccfc1de2341ce044a68c9345d53599e (diff) |
glsl: simplify set_opaque_binding()
While we are at it, update the GLSL spec comment.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r-- | src/compiler/glsl/link_uniform_initializers.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp index 79a6c75aaa8..a7af75586e7 100644 --- a/src/compiler/glsl/link_uniform_initializers.cpp +++ b/src/compiler/glsl/link_uniform_initializers.cpp @@ -117,7 +117,7 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog, const unsigned elements = MAX2(storage->array_elements, 1); - /* Section 4.4.4 (Opaque-Uniform Layout Qualifiers) of the GLSL 4.20 spec + /* Section 4.4.6 (Opaque-Uniform Layout Qualifiers) of the GLSL 4.50 spec * says: * * "If the binding identifier is used with an array, the first element @@ -129,27 +129,26 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog, } for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) { - gl_linked_shader *shader = prog->_LinkedShaders[sh]; - - if (shader) { - if (storage->type->is_sampler() && storage->opaque[sh].active) { - for (unsigned i = 0; i < elements; i++) { - const unsigned index = storage->opaque[sh].index + i; - if (index >= ARRAY_SIZE(shader->Program->SamplerUnits)) - break; - shader->Program->SamplerUnits[index] = - storage->storage[i].i; - } + gl_linked_shader *shader = prog->_LinkedShaders[sh]; - } else if (storage->type->is_image() && - storage->opaque[sh].active) { - for (unsigned i = 0; i < elements; i++) { - const unsigned index = storage->opaque[sh].index + i; - if (index >= ARRAY_SIZE(shader->Program->sh.ImageUnits)) - break; - shader->Program->sh.ImageUnits[index] = - storage->storage[i].i; - } + if (!shader) + continue; + if (!storage->opaque[sh].active) + continue; + + if (storage->type->is_sampler()) { + for (unsigned i = 0; i < elements; i++) { + const unsigned index = storage->opaque[sh].index + i; + if (index >= ARRAY_SIZE(shader->Program->SamplerUnits)) + break; + shader->Program->SamplerUnits[index] = storage->storage[i].i; + } + } else if (storage->type->is_image()) { + for (unsigned i = 0; i < elements; i++) { + const unsigned index = storage->opaque[sh].index + i; + if (index >= ARRAY_SIZE(shader->Program->sh.ImageUnits)) + break; + shader->Program->sh.ImageUnits[index] = storage->storage[i].i; } } } |