mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 08:40:11 +01:00
nir: add nir_lower_constant_to_temp helper
this comes up with clc. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32382>
This commit is contained in:
parent
12cc22af4c
commit
c2973765e2
2 changed files with 19 additions and 0 deletions
|
|
@ -5561,6 +5561,7 @@ void nir_fixup_deref_modes(nir_shader *shader);
|
|||
void nir_fixup_deref_types(nir_shader *shader);
|
||||
|
||||
bool nir_lower_global_vars_to_local(nir_shader *shader);
|
||||
void nir_lower_constant_to_temp(nir_shader *shader);
|
||||
|
||||
typedef enum {
|
||||
nir_lower_direct_array_deref_of_vec_load = (1 << 0),
|
||||
|
|
|
|||
|
|
@ -1561,3 +1561,21 @@ nir_opt_deref(nir_shader *shader)
|
|||
|
||||
return progress;
|
||||
}
|
||||
|
||||
/*
|
||||
* With library-based approaches to driver shaders, it may not be possible to
|
||||
* implement constant_data directly, but LLVM loves to produce constants e.g.
|
||||
* for designated initializers. This helper lowers away constant data. This may
|
||||
* allow additional optimizations. If desired, the backend driver can regather
|
||||
* constant data later with nir_opt_large_constants.
|
||||
*/
|
||||
void
|
||||
nir_lower_constant_to_temp(nir_shader *nir)
|
||||
{
|
||||
nir_foreach_variable_with_modes(var, nir, nir_var_mem_constant) {
|
||||
var->data.mode = nir_var_shader_temp;
|
||||
}
|
||||
|
||||
nir_fixup_deref_modes(nir);
|
||||
nir_lower_global_vars_to_local(nir);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue