Module: Mesa Branch: main Commit: 4584acca6b3f4be649b1c2f495ff88a929484b35 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4584acca6b3f4be649b1c2f495ff88a929484b35
Author: Timothy Arceri <[email protected]> Date: Mon Dec 18 16:16:18 2023 +1100 glsl: tidy up validation loop in linker There is no need to have a separate loop to determine the first stage in the shader program. Previously there were other users of this but since this is the last remain user this patch changes the code to simply detect the first stage directly. Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26747> --- src/compiler/glsl/linker.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index a4b233c74ac..6b4defaa3a3 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2868,6 +2868,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) #endif void *mem_ctx = ralloc_context(NULL); // temporary linker context + unsigned prev = MESA_SHADER_STAGES; /* Separate the shaders into groups based on their type. */ @@ -3032,17 +3033,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) if (!prog->data->LinkStatus) goto done; - unsigned first, prev; - - first = MESA_SHADER_STAGES; - /* 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; - } - check_explicit_uniform_locations(&ctx->Extensions, prog); link_assign_subroutine_types(prog); verify_subroutine_associated_funcs(prog); @@ -3055,11 +3045,15 @@ 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++) { + for (unsigned i = 0; i <= MESA_SHADER_FRAGMENT; i++) { if (prog->_LinkedShaders[i] == NULL) continue; + if (prev == MESA_SHADER_STAGES) { + prev = i; + continue; + } + validate_interstage_inout_blocks(prog, prog->_LinkedShaders[prev], prog->_LinkedShaders[i]); if (!prog->data->LinkStatus)
