diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 857c4cd3a40..ae5eb7ddad8 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -1485,6 +1485,15 @@ gl_nir_link_glsl(const struct gl_constants *consts, last = i; } + /* Implement the GLSL 1.30+ rule for discard vs infinite loops. + * This rule also applies to GLSL ES 3.00. + */ + if (prog->GLSL_Version >= (prog->IsES ? 300 : 130)) { + struct gl_linked_shader *sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; + if (sh) + gl_nir_lower_discard_flow(sh->Program->nir); + } + gl_nir_lower_named_interface_blocks(prog); /* Validate the inputs of each stage with the output of the preceding diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 4acf396161e..ca41401d28c 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2820,19 +2820,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) prog->_LinkedShaders[MESA_SHADER_FRAGMENT])) goto done; - /* Implement the GLSL 1.30+ rule for discard vs infinite loops Do - * it before optimization because we want most of the checks to get - * dropped thanks to constant propagation. - * - * This rule also applies to GLSL ES 3.00. - */ - if (max_version >= (prog->IsES ? 300 : 130)) { - struct gl_linked_shader *sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; - if (sh) { - lower_discard_flow(sh->ir); - } - } - for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue;