diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index afa17c4ed8e..120db7e1acd 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -1677,6 +1677,32 @@ gl_nir_link_glsl(const struct gl_constants *consts, MESA_TRACE_FUNC(); + /* Validate the inputs of each stage with the output of the preceding + * stage. + */ + unsigned prev = MESA_SHADER_STAGES; + for (unsigned i = 0; i <= MESA_SHADER_FRAGMENT; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + if (prev == MESA_SHADER_STAGES) { + prev = i; + continue; + } + + gl_nir_validate_interstage_inout_blocks(prog, prog->_LinkedShaders[prev], + prog->_LinkedShaders[i]); + if (!prog->data->LinkStatus) + return false; + + prev = i; + } + + /* Cross-validate uniform blocks between shader stages */ + gl_nir_validate_interstage_uniform_blocks(prog, prog->_LinkedShaders); + if (!prog->data->LinkStatus) + return false; + if (prog->IsES && prog->GLSL_Version == 100) if (!validate_invariant_builtins(consts, prog, prog->_LinkedShaders[MESA_SHADER_VERTEX], @@ -1721,7 +1747,7 @@ gl_nir_link_glsl(const struct gl_constants *consts, /* Validate the inputs of each stage with the output of the preceding * stage. */ - unsigned prev = first; + prev = first; for (unsigned i = prev + 1; i <= MESA_SHADER_FRAGMENT; i++) { if (prog->_LinkedShaders[i] == NULL) continue; diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 706bafdde55..75c30b3d5ce 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2554,7 +2554,6 @@ 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. */ @@ -2728,31 +2727,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) resize_tes_inputs(consts, prog); - /* Validate the inputs of each stage with the output of the preceding - * stage. - */ - 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) - goto done; - - prev = i; - } - - /* Cross-validate uniform blocks between shader stages */ - validate_interstage_uniform_blocks(prog, prog->_LinkedShaders); - if (!prog->data->LinkStatus) - goto done; - done: for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { free(shader_list[i]);