summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2015-11-21 19:02:00 +1100
committerTimothy Arceri <[email protected]>2015-11-25 09:49:48 +1100
commit404ac4bf9e2e0ed388edc3553a6b9a31d59d7e03 (patch)
tree874d192ab1c3a0b4d55a0412f1cfe5036df64a4c /src
parent0ce370a84b1c9381b34769dc4958e0ef413502f6 (diff)
glsl: move and reused code to find first and last shaders
Reviewed-by: Juha-Pekka Heikkila <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/linker.cpp30
1 files changed, 12 insertions, 18 deletions
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: