Module: Mesa Branch: main Commit: 8cfb46e27dfb12acdb1a00f7687a43899d770cca URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8cfb46e27dfb12acdb1a00f7687a43899d770cca
Author: Neha Bhende <[email protected]> Date: Tue Oct 17 15:58:23 2023 -0700 ntt: lower indirect tesslevels in ntt Tessellation shader which are using indirect addressing for tesslevels e.g gl_TessLevelOuter[gl_InvocationID] = tessLevelOuter; are crashing because gl_TessLevelOuter is now a compact array variable and nir expects a constant array index into the compact array variable. This patch handles such cases. This fixes MR 21940 Fixes: 84006587d7e5 ("glsl: Delete the lower_tess_level pass.") Tested with glretrace Reviewed-by: Charmaine Lee <[email protected]> Reviewed-by: Emma Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25773> --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 521a643d0fb..4cf7fbc20c4 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -3898,6 +3898,15 @@ const void *nir_to_tgsi_options(struct nir_shader *s, NIR_PASS_V(s, nir_remove_dead_variables, nir_var_shader_in, NULL); } + /* Lower tesslevel indirect derefs for tessellation shader. + * tesslevels are now a compact array variable and nir expects a constant + * array index into the compact array variable. + */ + if (s->info.stage == MESA_SHADER_TESS_CTRL || + s->info.stage == MESA_SHADER_TESS_EVAL) { + NIR_PASS_V(s, nir_lower_indirect_derefs, 0 , UINT32_MAX); + } + NIR_PASS_V(s, nir_lower_io, nir_var_shader_in | nir_var_shader_out, type_size, (nir_lower_io_options)0);
