gallivm: rework translator to allow per-impl work.

This allows a function implementation to be targetted, this will
only be used by the compute shader paths, so keep a compat path
for all the others.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24687>
This commit is contained in:
Dave Airlie 2020-10-27 10:00:14 +10:00 committed by Marge Bot
parent 3cd20feed0
commit b8e93abd11
4 changed files with 33 additions and 17 deletions

View file

@ -2870,10 +2870,9 @@ lp_build_nir_prepasses(struct nir_shader *nir)
}
bool lp_build_nir_llvm(struct lp_build_nir_context *bld_base,
struct nir_shader *nir)
struct nir_shader *nir,
nir_function_impl *impl)
{
struct nir_function *func;
nir_foreach_shader_out_variable(variable, nir)
handle_shader_output_decl(bld_base, nir, variable);
@ -2899,17 +2898,15 @@ bool lp_build_nir_llvm(struct lp_build_nir_context *bld_base,
_mesa_key_pointer_equal);
bld_base->range_ht = _mesa_pointer_hash_table_create(NULL);
func = (struct nir_function *)exec_list_get_head(&nir->functions);
nir_foreach_reg_decl(reg, func->impl) {
nir_foreach_reg_decl(reg, impl) {
LLVMTypeRef type = get_register_type(bld_base, reg);
LLVMValueRef reg_alloc = lp_build_alloca(bld_base->base.gallivm,
type, "reg");
_mesa_hash_table_insert(bld_base->regs, reg, reg_alloc);
}
nir_index_ssa_defs(func->impl);
bld_base->ssa_defs = calloc(func->impl->ssa_alloc, sizeof(LLVMValueRef));
visit_cf_list(bld_base, &func->impl->body);
nir_index_ssa_defs(impl);
bld_base->ssa_defs = calloc(impl->ssa_alloc, sizeof(LLVMValueRef));
visit_cf_list(bld_base, &impl->body);
free(bld_base->ssa_defs);
ralloc_free(bld_base->vars);

View file

@ -40,6 +40,12 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
const struct lp_build_tgsi_params *params,
LLVMValueRef (*outputs)[4]);
void lp_build_nir_soa_func(struct gallivm_state *gallivm,
struct nir_shader *shader,
nir_function_impl *impl,
const struct lp_build_tgsi_params *params,
LLVMValueRef (*outputs)[4]);
void lp_build_nir_aos(struct gallivm_state *gallivm,
struct nir_shader *shader,
struct lp_type type,
@ -300,7 +306,8 @@ lp_build_nir_prepasses(struct nir_shader *nir);
bool
lp_build_nir_llvm(struct lp_build_nir_context *bld_base,
struct nir_shader *nir);
struct nir_shader *nir,
nir_function_impl *impl);
void
lp_build_opt_nir(struct nir_shader *nir);

View file

@ -397,5 +397,6 @@ lp_build_nir_aos(struct gallivm_state *gallivm,
lp_build_nir_prepasses(shader);
NIR_PASS_V(shader, nir_move_vec_src_uses_to_dest);
NIR_PASS_V(shader, nir_lower_vec_to_regs, NULL, NULL);
lp_build_nir_llvm(&bld.bld_base, shader);
lp_build_nir_llvm(&bld.bld_base, shader,
nir_shader_get_entrypoint(shader));
}

View file

@ -2800,10 +2800,11 @@ emit_clock(struct lp_build_nir_context *bld_base,
dst[1] = lp_build_broadcast_scalar(uint_bld, hi);
}
void lp_build_nir_soa(struct gallivm_state *gallivm,
struct nir_shader *shader,
const struct lp_build_tgsi_params *params,
LLVMValueRef (*outputs)[4])
void lp_build_nir_soa_func(struct gallivm_state *gallivm,
struct nir_shader *shader,
nir_function_impl *impl,
const struct lp_build_tgsi_params *params,
LLVMValueRef (*outputs)[4])
{
struct lp_build_nir_soa_context bld;
const struct lp_type type = params->type;
@ -2973,8 +2974,7 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
}
emit_prologue(&bld);
lp_build_nir_prepasses(shader);
lp_build_nir_llvm(&bld.bld_base, shader);
lp_build_nir_llvm(&bld.bld_base, shader, impl);
if (bld.gs_iface) {
LLVMBuilderRef builder = bld.bld_base.base.gallivm->builder;
@ -2996,3 +2996,14 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
}
lp_exec_mask_fini(&bld.exec_mask);
}
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_func(gallivm, shader,
nir_shader_get_entrypoint(shader),
params, outputs);
}