nir: Drop the mode argument of nir_lower_vars_to_scratch().

It only makes sense for function temps, and that's the only way it's been
used.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37245>
This commit is contained in:
Emma Anholt 2025-09-05 09:39:16 -07:00 committed by Marge Bot
parent 962bed2dd6
commit 059d301c79
11 changed files with 9 additions and 13 deletions

View file

@ -227,7 +227,7 @@ ac_nir_lower_indirect_derefs(nir_shader *shader,
/* Lower large variables to scratch first so that we won't bloat the /* Lower large variables to scratch first so that we won't bloat the
* shader by generating large if ladders for them. * shader by generating large if ladders for them.
*/ */
NIR_PASS(progress, shader, nir_lower_vars_to_scratch, nir_var_function_temp, 256, NIR_PASS(progress, shader, nir_lower_vars_to_scratch, 256,
glsl_get_natural_size_align_bytes, glsl_get_natural_size_align_bytes); glsl_get_natural_size_align_bytes, glsl_get_natural_size_align_bytes);
/* This lowers indirect indexing to if-else ladders. */ /* This lowers indirect indexing to if-else ladders. */

View file

@ -3685,7 +3685,7 @@ agx_preprocess_nir(nir_shader *nir)
NIR_PASS(_, nir, nir_lower_vars_to_ssa); NIR_PASS(_, nir, nir_lower_vars_to_ssa);
/* Lower large arrays to scratch and small arrays to csel */ /* Lower large arrays to scratch and small arrays to csel */
NIR_PASS(_, nir, nir_lower_vars_to_scratch, nir_var_function_temp, 256, NIR_PASS(_, nir, nir_lower_vars_to_scratch, 256,
glsl_get_natural_size_align_bytes, glsl_get_word_size_align_bytes); glsl_get_natural_size_align_bytes, glsl_get_word_size_align_bytes);
NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees, NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees,
nir_var_function_temp, ~0); nir_var_function_temp, ~0);
@ -3801,7 +3801,7 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
/* Optimize scratch access for silly internal CL shaders */ /* Optimize scratch access for silly internal CL shaders */
if (nir->info.internal) { if (nir->info.internal) {
NIR_PASS(_, nir, nir_lower_scratch_to_var); NIR_PASS(_, nir, nir_lower_scratch_to_var);
NIR_PASS(_, nir, nir_lower_vars_to_scratch, nir_var_function_temp, 256, NIR_PASS(_, nir, nir_lower_vars_to_scratch, 256,
glsl_get_natural_size_align_bytes, glsl_get_natural_size_align_bytes,
glsl_get_natural_size_align_bytes); glsl_get_natural_size_align_bytes);
NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees, NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees,

View file

@ -1839,7 +1839,6 @@ v3d_attempt_compile(struct v3d_compile *c)
} }
NIR_PASS(_, c->s, nir_lower_vars_to_scratch, NIR_PASS(_, c->s, nir_lower_vars_to_scratch,
nir_var_function_temp,
0, 0,
glsl_get_natural_size_align_bytes, glsl_get_natural_size_align_bytes,
glsl_get_natural_size_align_bytes); glsl_get_natural_size_align_bytes);

View file

@ -5190,7 +5190,6 @@ bool nir_lower_io_vars_to_temporaries(nir_shader *shader,
nir_variable_mode modes); nir_variable_mode modes);
bool nir_lower_vars_to_scratch(nir_shader *shader, bool nir_lower_vars_to_scratch(nir_shader *shader,
nir_variable_mode modes,
int size_threshold, int size_threshold,
glsl_type_size_align_func variable_size_align, glsl_type_size_align_func variable_size_align,
glsl_type_size_align_func scratch_layout_size_align); glsl_type_size_align_func scratch_layout_size_align);

View file

@ -93,7 +93,6 @@ only_used_for_load_store(nir_deref_instr *deref)
bool bool
nir_lower_vars_to_scratch(nir_shader *shader, nir_lower_vars_to_scratch(nir_shader *shader,
nir_variable_mode modes,
int size_threshold, int size_threshold,
glsl_type_size_align_func variable_size_align, glsl_type_size_align_func variable_size_align,
glsl_type_size_align_func scratch_layout_size_align) glsl_type_size_align_func scratch_layout_size_align)
@ -115,7 +114,7 @@ nir_lower_vars_to_scratch(nir_shader *shader,
continue; continue;
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]); nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
if (!nir_deref_mode_is_one_of(deref, modes)) if (!nir_deref_mode_is_one_of(deref, nir_var_function_temp))
continue; continue;
if (!nir_deref_instr_has_indirect(nir_src_as_deref(intrin->src[0]))) if (!nir_deref_instr_has_indirect(nir_src_as_deref(intrin->src[0])))
@ -227,3 +226,4 @@ nir_lower_vars_to_scratch(nir_shader *shader,
return progress; return progress;
} }

View file

@ -1199,7 +1199,7 @@ ir3_nir_lower_variant(struct ir3_shader_variant *so,
* expensive. * expensive.
*/ */
if (so->compiler->has_pvtmem) { if (so->compiler->has_pvtmem) {
progress |= OPT(s, nir_lower_vars_to_scratch, nir_var_function_temp, progress |= OPT(s, nir_lower_vars_to_scratch,
16 * 16 /* bytes */, 16 * 16 /* bytes */,
ir3_get_variable_size_align_bytes, glsl_get_natural_size_align_bytes); ir3_get_variable_size_align_bytes, glsl_get_natural_size_align_bytes);
} }

View file

@ -869,7 +869,6 @@ r600_lower_and_optimize_nir(nir_shader *sh,
NIR_PASS(_, NIR_PASS(_,
sh, sh,
nir_lower_vars_to_scratch, nir_lower_vars_to_scratch,
nir_var_function_temp,
64, 64,
r600_get_scratch_size_align, r600_get_scratch_size_align,
r600_get_scratch_size_align); r600_get_scratch_size_align);

View file

@ -596,7 +596,6 @@ void pco_preprocess_nir(pco_ctx *ctx, nir_shader *nir)
NIR_PASS(_, NIR_PASS(_,
nir, nir,
nir_lower_vars_to_scratch, nir_lower_vars_to_scratch,
nir_var_function_temp,
8, 8,
glsl_get_natural_size_align_bytes, glsl_get_natural_size_align_bytes,
glsl_get_word_size_align_bytes); glsl_get_word_size_align_bytes);

View file

@ -1931,7 +1931,7 @@ msl_preprocess_nir(struct nir_shader *nir)
NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees, NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees,
nir_var_shader_in | nir_var_shader_out, UINT32_MAX); nir_var_shader_in | nir_var_shader_out, UINT32_MAX);
NIR_PASS(_, nir, nir_lower_vars_to_scratch, nir_var_function_temp, 0, NIR_PASS(_, nir, nir_lower_vars_to_scratch, 0,
glsl_get_natural_size_align_bytes, glsl_get_natural_size_align_bytes,
glsl_get_natural_size_align_bytes); glsl_get_natural_size_align_bytes);

View file

@ -442,7 +442,7 @@ kk_lower_nir(struct kk_device *dev, nir_shader *nir,
/* kk_nir_lower_vs_multiview may create a temporary array to assign the /* kk_nir_lower_vs_multiview may create a temporary array to assign the
* correct view index. Since we don't handle derefs, we need to get rid of * correct view index. Since we don't handle derefs, we need to get rid of
* them. */ * them. */
NIR_PASS(_, nir, nir_lower_vars_to_scratch, nir_var_function_temp, 0, NIR_PASS(_, nir, nir_lower_vars_to_scratch, 0,
glsl_get_natural_size_align_bytes, glsl_get_natural_size_align_bytes,
glsl_get_natural_size_align_bytes); glsl_get_natural_size_align_bytes);

View file

@ -6238,7 +6238,7 @@ bifrost_preprocess_nir(nir_shader *nir, unsigned gpu_id)
: glsl_get_natural_size_align_bytes; : glsl_get_natural_size_align_bytes;
/* Lower large arrays to scratch and small arrays to bcsel */ /* Lower large arrays to scratch and small arrays to bcsel */
NIR_PASS(_, nir, nir_lower_scratch_to_var); NIR_PASS(_, nir, nir_lower_scratch_to_var);
NIR_PASS(_, nir, nir_lower_vars_to_scratch, nir_var_function_temp, 256, NIR_PASS(_, nir, nir_lower_vars_to_scratch, 256,
vars_to_scratch_size_align_func, vars_to_scratch_size_align_func); vars_to_scratch_size_align_func, vars_to_scratch_size_align_func);
NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees, NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees,
nir_var_function_temp, ~0); nir_var_function_temp, ~0);