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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26747>
This commit is contained in:
Timothy Arceri
2023-12-18 16:16:18 +11:00
committed by Marge Bot
parent 670a799ebf
commit 4584acca6b
+7 -13
View File
@@ -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)