diff options
author | Dave Airlie <airlied@redhat.com> | 2020-10-27 10:00:14 +1000 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-09-12 01:57:50 +0000 |
commit | b8e93abd113941debba723b1b1284c581505e6f1 (patch) | |
tree | 8425cf5d7ef9284e8773d738644afdf5d53f1cb7 /src/gallium/auxiliary | |
parent | 3cd20feed07530e09b64bd81901babc9a697b107 (diff) | |
download | mesa-b8e93abd113941debba723b1b1284c581505e6f1.tar.gz mesa-b8e93abd113941debba723b1b1284c581505e6f1.tar.bz2 mesa-b8e93abd113941debba723b1b1284c581505e6f1.zip |
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>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_nir.c | 15 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_nir.h | 9 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_nir_aos.c | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 23 |
4 files changed, 33 insertions, 17 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 7fd20509791..aab7c807a4e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -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); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.h b/src/gallium/auxiliary/gallivm/lp_bld_nir.h index 443a7b4c22a..14e77d72f01 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.h @@ -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); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_aos.c index f1da5b10120..6ede0950c60 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_aos.c @@ -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)); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index cd4438eaf23..baa533e334c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -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); +} |