glsl: don't lower outputs to temps unconditionally

It's done later in nir_lower_io_passes only for shader stages not
supporting indirect access.

Unfortunately we have add a hack into nir_lower_io_passes to get rid of
output loads. A later commit will remove it.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35945>
This commit is contained in:
Marek Olšák 2025-07-04 13:17:35 -04:00 committed by Marge Bot
parent 1124587495
commit a065a09d22
2 changed files with 12 additions and 3 deletions

View file

@ -1326,9 +1326,6 @@ preprocess_shader(const struct gl_constants *consts,
(nir->info.outputs_written & (VARYING_BIT_CLIP_DIST0 | VARYING_BIT_CLIP_DIST1)))
NIR_PASS(_, nir, gl_nir_zero_initialize_clip_distance);
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
nir_shader_get_entrypoint(nir), true, false);
NIR_PASS(_, nir, nir_lower_global_vars_to_local);
NIR_PASS(_, nir, nir_split_var_copies);
NIR_PASS(_, nir, nir_lower_var_copies);

View file

@ -1038,6 +1038,18 @@ nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs)
(nir->options->support_indirect_outputs >> nir->info.stage) & 0x1 &&
nir->xfb_info == NULL;
/* TODO: This is a hack until a better solution is available.
* For all shaders except TCS, lower all outputs to temps because:
* - there can be output loads (nobody expects those outside of TCS)
* - drivers don't expect when an output is only written in control flow
*
* "has_indirect_outputs = false" causes all outputs to be lowered to temps.
* which lowers indirect stores, eliminates output loads, and moves all
* output stores to the end or GS emits.
*/
if (nir->info.stage != MESA_SHADER_TESS_CTRL)
has_indirect_outputs = false;
/* TODO: Sorting variables by location is required due to some bug
* in nir_lower_io_vars_to_temporaries. If variables are not sorted,
* dEQP-GLES31.functional.separate_shader.random.0 fails.