diff options
author | Dave Airlie <[email protected]> | 2019-09-05 15:49:25 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2019-11-28 14:49:23 +1000 |
commit | 18f896e55d96c63b11de7ed0cbe484988a1184c5 (patch) | |
tree | 53f3de40752f42d63829b45127c1adaa482004d7 /src/gallium/drivers/llvmpipe/lp_state_cs.c | |
parent | 5363cda52b84124b2b93d22d34fc8ebf6302bdae (diff) |
llvmpipe: add initial nir support
This adds the hooks between llvmpipe and the gallivm NIR
code, for compute and fragment shaders.
NIR support is hidden behind LP_DEBUG=nir for now until
all the intergration issues are solved
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_state_cs.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_cs.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index a26cbf4df22..e98927acf7b 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -35,6 +35,7 @@ #include "gallivm/lp_bld_flow.h" #include "gallivm/lp_bld_gather.h" #include "gallivm/lp_bld_coro.h" +#include "gallivm/lp_bld_nir.h" #include "lp_state_cs.h" #include "lp_context.h" #include "lp_debug.h" @@ -44,6 +45,7 @@ #include "lp_memory.h" #include "lp_cs_tpool.h" #include "state_tracker/sw_winsys.h" +#include "nir/nir_to_tgsi_info.h" struct lp_cs_job_info { unsigned grid_size[3]; @@ -272,7 +274,6 @@ generate_compute(struct llvmpipe_context *lp, block = LLVMAppendBasicBlockInContext(gallivm->context, coro, "entry"); LLVMPositionBuilderAtEnd(builder, block); { - const struct tgsi_token *tokens = shader->base.tokens; LLVMValueRef consts_ptr, num_consts_ptr; LLVMValueRef ssbo_ptr, num_ssbo_ptr; LLVMValueRef shared_ptr; @@ -360,7 +361,11 @@ generate_compute(struct llvmpipe_context *lp, params.shared_ptr = shared_ptr; params.coro = &coro_info; - lp_build_tgsi_soa(gallivm, tokens, ¶ms, NULL); + if (shader->base.type == PIPE_SHADER_IR_TGSI) + lp_build_tgsi_soa(gallivm, shader->base.tokens, ¶ms, NULL); + else + lp_build_nir_soa(gallivm, shader->base.ir.nir, ¶ms, + NULL); mask_val = lp_build_mask_end(&mask); @@ -393,11 +398,19 @@ llvmpipe_create_compute_state(struct pipe_context *pipe, if (!shader) return NULL; - assert(templ->ir_type == PIPE_SHADER_IR_TGSI); - shader->base.tokens = tgsi_dup_tokens(templ->prog); + shader->base.type = templ->ir_type; + if (templ->ir_type == PIPE_SHADER_IR_TGSI) { + /* get/save the summary info for this shader */ + lp_build_tgsi_info(templ->prog, &shader->info); + + /* we need to keep a local copy of the tokens */ + shader->base.tokens = tgsi_dup_tokens(templ->prog); + } else { + shader->base.ir.nir = (struct nir_shader *)templ->prog; + nir_tgsi_scan_shader(templ->prog, &shader->info.base, false); + } shader->req_local_mem = templ->req_local_mem; - lp_build_tgsi_info(shader->base.tokens, &shader->info); make_empty_list(&shader->variants); nr_samplers = shader->info.base.file_max[TGSI_FILE_SAMPLER] + 1; @@ -590,7 +603,10 @@ lp_debug_cs_variant(const struct lp_compute_shader_variant *variant) { debug_printf("llvmpipe: Compute shader #%u variant #%u:\n", variant->shader->no, variant->no); - tgsi_dump(variant->shader->base.tokens, 0); + if (variant->shader->base.type == PIPE_SHADER_IR_TGSI) + tgsi_dump(variant->shader->base.tokens, 0); + else + nir_print_shader(variant->shader->base.ir.nir, stderr); dump_cs_variant_key(&variant->key); debug_printf("\n"); } |