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-05 12:33:55 +0200
commitb8466d9a83f29a29d9e62191f10c2099e201e5b5 (patch)
treef21bdd1ddbecb59022f9d841cf2e02ecd2d0e23e
parent7d4e25c727b0bc6fdd35c58e444203d180722410 (diff)
ac/nir: use shader_info pass to determine whether instance_id is used
This improves the separation of ABI and NIR translation.
-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 301cb837c8..e5f28f20ea 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3997,8 +3997,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;
@@ -6152,6 +6150,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;