gallivm: Split nir prepasses into aos/soa

The soa backend will work on very different looking NIR in the future.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32963>
This commit is contained in:
Konstantin Seurer 2024-12-06 17:14:25 +01:00 committed by Marge Bot
parent efa23ef664
commit daad0f8a91
5 changed files with 18 additions and 14 deletions

View file

@ -2951,16 +2951,6 @@ get_register_type(struct lp_build_nir_context *bld_base,
return type;
}
void
lp_build_nir_prepasses(struct nir_shader *nir)
{
NIR_PASS_V(nir, nir_convert_to_lcssa, true, true);
NIR_PASS_V(nir, nir_convert_from_ssa, true, false);
NIR_PASS_V(nir, nir_lower_locals_to_regs, 32);
NIR_PASS_V(nir, nir_remove_dead_derefs);
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
}
bool lp_build_nir_llvm(struct lp_build_nir_context *bld_base,
struct nir_shader *nir,
nir_function_impl *impl)

View file

@ -326,7 +326,7 @@ struct lp_build_nir_soa_context
};
void
lp_build_nir_prepasses(struct nir_shader *nir);
lp_build_nir_soa_prepasses(struct nir_shader *nir);
bool
lp_build_nir_llvm(struct lp_build_nir_context *bld_base,

View file

@ -394,7 +394,11 @@ lp_build_nir_aos(struct gallivm_state *gallivm,
bld.bld_base.tex = emit_tex;
bld.bld_base.emit_var_decl = emit_var_decl;
lp_build_nir_prepasses(shader);
NIR_PASS_V(shader, nir_convert_to_lcssa, true, true);
NIR_PASS_V(shader, nir_convert_from_ssa, true, false);
NIR_PASS_V(shader, nir_lower_locals_to_regs, 32);
NIR_PASS_V(shader, nir_remove_dead_derefs);
NIR_PASS_V(shader, nir_remove_dead_variables, nir_var_function_temp, NULL);
NIR_PASS_V(shader, nir_move_vec_src_uses_to_dest, false);
NIR_PASS_V(shader, nir_lower_vec_to_regs, NULL, NULL);
lp_build_nir_llvm(&bld.bld_base, shader,

View file

@ -3246,12 +3246,22 @@ void lp_build_nir_soa_func(struct gallivm_state *gallivm,
lp_exec_mask_fini(&bld.exec_mask);
}
void
lp_build_nir_soa_prepasses(struct nir_shader *nir)
{
NIR_PASS_V(nir, nir_convert_to_lcssa, true, true);
NIR_PASS_V(nir, nir_convert_from_ssa, true, false);
NIR_PASS_V(nir, nir_lower_locals_to_regs, 32);
NIR_PASS_V(nir, nir_remove_dead_derefs);
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
}
void lp_build_nir_soa(struct gallivm_state *gallivm,
struct nir_shader *shader,
const struct lp_build_tgsi_params *params,
LLVMValueRef (*outputs)[4])
{
lp_build_nir_prepasses(shader);
lp_build_nir_soa_prepasses(shader);
lp_build_nir_soa_func(gallivm, shader,
nir_shader_get_entrypoint(shader),
params, outputs);

View file

@ -447,7 +447,7 @@ generate_compute(struct llvmpipe_context *lp,
lp_build_name(thread_data_ptr, "thread_data");
lp_build_name(io_ptr, "vertex_io");
lp_build_nir_prepasses(nir);
lp_build_nir_soa_prepasses(nir);
struct hash_table *fns = _mesa_pointer_hash_table_create(NULL);
sampler = lp_llvm_sampler_soa_create(lp_cs_variant_key_samplers(key),