ac/nir,radeonsi: add ac_shader_abi::front_face

v2: update for LLVMValueRefs in ac_shader_abi

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Nicolai Hähnle
2017-06-25 12:56:49 +02:00
parent 28634ff7d3
commit e247357240
3 changed files with 15 additions and 7 deletions

View File

@@ -132,7 +132,6 @@ struct nir_to_llvm_context {
LLVMValueRef sample_pos_offset; LLVMValueRef sample_pos_offset;
LLVMValueRef persp_sample, persp_center, persp_centroid; LLVMValueRef persp_sample, persp_center, persp_centroid;
LLVMValueRef linear_sample, linear_center, linear_centroid; LLVMValueRef linear_sample, linear_center, linear_centroid;
LLVMValueRef front_face;
LLVMValueRef ancillary; LLVMValueRef ancillary;
LLVMValueRef sample_coverage; LLVMValueRef sample_coverage;
LLVMValueRef frag_pos[4]; LLVMValueRef frag_pos[4];
@@ -816,7 +815,7 @@ static void create_function(struct nir_to_llvm_context *ctx)
add_vgpr_argument(&args, ctx->f32, &ctx->frag_pos[1]); /* pos y float */ add_vgpr_argument(&args, ctx->f32, &ctx->frag_pos[1]); /* pos y float */
add_vgpr_argument(&args, ctx->f32, &ctx->frag_pos[2]); /* pos z float */ add_vgpr_argument(&args, ctx->f32, &ctx->frag_pos[2]); /* pos z float */
add_vgpr_argument(&args, ctx->f32, &ctx->frag_pos[3]); /* pos w float */ add_vgpr_argument(&args, ctx->f32, &ctx->frag_pos[3]); /* pos w float */
add_vgpr_argument(&args, ctx->i32, &ctx->front_face); /* front face */ add_vgpr_argument(&args, ctx->i32, &ctx->abi.front_face); /* front face */
add_vgpr_argument(&args, ctx->i32, &ctx->ancillary); /* ancillary */ add_vgpr_argument(&args, ctx->i32, &ctx->ancillary); /* ancillary */
add_vgpr_argument(&args, ctx->i32, &ctx->sample_coverage); /* sample coverage */ add_vgpr_argument(&args, ctx->i32, &ctx->sample_coverage); /* sample coverage */
add_vgpr_argument(&args, ctx->i32, NULL); /* fixed pt */ add_vgpr_argument(&args, ctx->i32, NULL); /* fixed pt */
@@ -4023,7 +4022,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
result = ctx->nctx->sample_coverage; result = ctx->nctx->sample_coverage;
break; break;
case nir_intrinsic_load_front_face: case nir_intrinsic_load_front_face:
result = ctx->nctx->front_face; result = ctx->abi->front_face;
break; break;
case nir_intrinsic_load_instance_id: case nir_intrinsic_load_instance_id:
result = ctx->abi->instance_id; result = ctx->abi->instance_id;

View File

@@ -44,6 +44,7 @@ struct ac_shader_abi {
LLVMValueRef draw_id; LLVMValueRef draw_id;
LLVMValueRef vertex_id; LLVMValueRef vertex_id;
LLVMValueRef instance_id; LLVMValueRef instance_id;
LLVMValueRef front_face;
/* For VS and PS: pre-loaded shader inputs. /* For VS and PS: pre-loaded shader inputs.
* *

View File

@@ -150,12 +150,19 @@ static unsigned add_arg(struct si_function_info *fninfo,
return add_arg_assign(fninfo, regfile, type, NULL); return add_arg_assign(fninfo, regfile, type, NULL);
} }
static void add_arg_assign_checked(struct si_function_info *fninfo,
enum si_arg_regfile regfile, LLVMTypeRef type,
LLVMValueRef *assign, unsigned idx)
{
MAYBE_UNUSED unsigned actual = add_arg_assign(fninfo, regfile, type, assign);
assert(actual == idx);
}
static void add_arg_checked(struct si_function_info *fninfo, static void add_arg_checked(struct si_function_info *fninfo,
enum si_arg_regfile regfile, LLVMTypeRef type, enum si_arg_regfile regfile, LLVMTypeRef type,
unsigned idx) unsigned idx)
{ {
MAYBE_UNUSED unsigned actual = add_arg(fninfo, regfile, type); add_arg_assign_checked(fninfo, regfile, type, NULL, idx);
assert(actual == idx);
} }
/** /**
@@ -1563,7 +1570,7 @@ static void declare_system_value(struct si_shader_context *ctx,
} }
case TGSI_SEMANTIC_FACE: case TGSI_SEMANTIC_FACE:
value = LLVMGetParam(ctx->main_fn, SI_PARAM_FRONT_FACE); value = ctx->abi.front_face;
break; break;
case TGSI_SEMANTIC_SAMPLEID: case TGSI_SEMANTIC_SAMPLEID:
@@ -4531,7 +4538,8 @@ static void create_function(struct si_shader_context *ctx)
add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_POS_Y_FLOAT); add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_POS_Y_FLOAT);
add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_POS_Z_FLOAT); add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_POS_Z_FLOAT);
add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_POS_W_FLOAT); add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_POS_W_FLOAT);
add_arg_checked(&fninfo, ARG_VGPR, ctx->i32, SI_PARAM_FRONT_FACE); add_arg_assign_checked(&fninfo, ARG_VGPR, ctx->i32,
&ctx->abi.front_face, SI_PARAM_FRONT_FACE);
shader->info.face_vgpr_index = 20; shader->info.face_vgpr_index = 20;
add_arg_checked(&fninfo, ARG_VGPR, ctx->i32, SI_PARAM_ANCILLARY); add_arg_checked(&fninfo, ARG_VGPR, ctx->i32, SI_PARAM_ANCILLARY);
add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_SAMPLE_COVERAGE); add_arg_checked(&fninfo, ARG_VGPR, ctx->f32, SI_PARAM_SAMPLE_COVERAGE);