From 29cf77957bb10bdec773bcba9700f228c0f5313b Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 15 Nov 2024 14:38:54 +1100 Subject: [PATCH] glsl: fix compiler global temp collisions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit glsl ir creates these temps to copy global initialiser values for example. To avoid collisions during linking due to 2 shaders in the same stage having temps with the same name we make sure to define these as function variables not shader globals. This will put the temps into the global instructions wrapper created in 7c5b21c03230. Fixes: cbfc225e2bda ("glsl: switch to a full nir based linker") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12136 Reviewed-by: Marek Olšák Part-of: (cherry picked from commit e34357015cfbe0bb2545f6509d66c76da3232e7b) --- .pick_status.json | 2 +- src/compiler/glsl/glsl_to_nir.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index f0836762f78..81e067b4d83 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1244,7 +1244,7 @@ "description": "glsl: fix compiler global temp collisions", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "cbfc225e2bda2c8627a4580fa3a9b63bfb7133e0", "notes": null diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 49db6d17e01..5e47477c8d9 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -481,11 +481,14 @@ nir_visitor::visit(ir_variable *ir) switch(ir->data.mode) { case ir_var_auto: - case ir_var_temporary: - if (is_global) + if (is_global) { var->data.mode = nir_var_shader_temp; - else - var->data.mode = nir_var_function_temp; + break; + } + + FALLTHROUGH; + case ir_var_temporary: + var->data.mode = nir_var_function_temp; break; case ir_var_function_in: