From: Timothy Arceri Date: Sat, 21 Nov 2015 08:02:00 +0000 (+1100) Subject: glsl: move and reused code to find first and last shaders X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=404ac4bf9e2e0ed388edc3553a6b9a31d59d7e03;p=mesa.git glsl: move and reused code to find first and last shaders Reviewed-by: Juha-Pekka Heikkila --- diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 331d9a28007..eac2536efc9 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -4139,11 +4139,18 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) if (!prog->LinkStatus) goto done; - unsigned prev; + unsigned first, last, prev; - for (prev = 0; prev <= MESA_SHADER_FRAGMENT; prev++) { - if (prog->_LinkedShaders[prev] != NULL) - break; + first = MESA_SHADER_STAGES; + last = 0; + + /* Determine first and last stage. */ + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { + if (!prog->_LinkedShaders[i]) + continue; + if (first == MESA_SHADER_STAGES) + first = i; + last = i; } check_explicit_uniform_locations(ctx, prog); @@ -4157,6 +4164,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Validate the inputs of each stage with the output of the preceding * stage. */ + prev = first; for (unsigned i = prev + 1; i <= MESA_SHADER_FRAGMENT; i++) { if (prog->_LinkedShaders[i] == NULL) continue; @@ -4260,20 +4268,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; } - unsigned first, last; - - first = MESA_SHADER_STAGES; - last = 0; - - /* Determine first and last stage. */ - for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { - if (!prog->_LinkedShaders[i]) - continue; - if (first == MESA_SHADER_STAGES) - first = i; - last = i; - } - if (num_tfeedback_decls != 0) { /* From GL_EXT_transform_feedback: * A program will fail to link if: