summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-06-26 14:36:47 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-07-31 14:55:39 +0200
commitba06e8bbe8c75ceeaf12dbddff40b2ad4124fe4b (patch)
tree7062ba0fa5a4ebcf750ec7ce3bd7da6993d8ba14
parentbe0488a1736d1f45d473d4f0c16243897a1d8491 (diff)
ac/nir: use shader_info pass to determine whether instance_id is used
This improves the separation of ABI and NIR translation. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--src/amd/common/ac_nir_to_llvm.c7
-rw-r--r--src/amd/common/ac_shader_info.c3
-rw-r--r--src/amd/common/ac_shader_info.h1
3 files changed, 9 insertions, 2 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index ec8006889d..a57fb2fc6b 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -4023,8 +4023,6 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
break;
case nir_intrinsic_load_instance_id:
result = ctx->abi->instance_id;
- ctx->nctx->shader_info->vs.vgpr_comp_cnt = MAX2(3,
- ctx->nctx->shader_info->vs.vgpr_comp_cnt);
break;
case nir_intrinsic_load_num_work_groups:
result = ctx->nctx->num_work_groups;
@@ -6229,6 +6227,11 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
ctx.gs_max_out_vertices = nir->info.gs.vertices_out;
} else if (nir->stage == MESA_SHADER_TESS_EVAL) {
ctx.tes_primitive_mode = nir->info.tess.primitive_mode;
+ } else if (nir->stage == MESA_SHADER_VERTEX) {
+ if (shader_info->info.vs.needs_instance_id) {
+ ctx.shader_info->vs.vgpr_comp_cnt =
+ MAX2(3, ctx.shader_info->vs.vgpr_comp_cnt);
+ }
}
ac_setup_rings(&ctx);
diff --git a/src/amd/common/ac_shader_info.c b/src/amd/common/ac_shader_info.c
index 13d73df11f..7d34535c10 100644
--- a/src/amd/common/ac_shader_info.c
+++ b/src/amd/common/ac_shader_info.c
@@ -39,6 +39,9 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, struct ac_shader_info *info)
case nir_intrinsic_load_draw_id:
info->vs.needs_draw_id = true;
break;
+ case nir_intrinsic_load_instance_id:
+ info->vs.needs_instance_id = true;
+ break;
case nir_intrinsic_load_num_work_groups:
info->cs.grid_components_used = instr->num_components;
break;
diff --git a/src/amd/common/ac_shader_info.h b/src/amd/common/ac_shader_info.h
index 5f03e79a83..5bc16cc9d0 100644
--- a/src/amd/common/ac_shader_info.h
+++ b/src/amd/common/ac_shader_info.h
@@ -33,6 +33,7 @@ struct ac_shader_info {
struct {
bool has_vertex_buffers; /* needs vertex buffers and base/start */
bool needs_draw_id;
+ bool needs_instance_id;
} vs;
struct {
bool needs_sample_positions;