From 8ceb10a1bdda07eb9a69742cebafdc0939fa4203 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Mon, 4 Mar 2024 11:22:16 +1100 Subject: [PATCH] glsl: make use of nir lower discard flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Marek Olšák Part-of: --- src/compiler/glsl/gl_nir_linker.c | 9 +++++++++ src/compiler/glsl/linker.cpp | 13 ------------- 2 files changed, 9 insertions(+), 13 deletions(-) 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;