diff options
author | Vincent Lejeune <[email protected]> | 2012-09-23 19:46:53 +0200 |
---|---|---|
committer | Vincent Lejeune <[email protected]> | 2012-10-09 23:19:09 +0200 |
commit | 11e08f42e4fa5f1d296429415be6da7c03f105b0 (patch) | |
tree | e0aebf47d328e826bbfda65d0a60c6b1ad541e59 /src/gallium/drivers | |
parent | 80663cb1859c3398804d720022eebcf9a0df1716 (diff) |
r600g: use a select to handle front/back color in llvm
Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/r600/r600_llvm.c | 36 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_shader.c | 13 |
2 files changed, 44 insertions, 5 deletions
diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c index 71ea5781220..c6e60afaba3 100644 --- a/src/gallium/drivers/r600/r600_llvm.c +++ b/src/gallium/drivers/r600/r600_llvm.c @@ -86,6 +86,42 @@ static void llvm_load_input( "llvm.R600.load.input", ctx->soa.bld_base.base.elem_type, ®, 1, LLVMReadNoneAttribute); + + if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR && ctx->two_side) { + unsigned back_reg = ctx->r600_inputs[input_index] + .potential_back_facing_reg; + unsigned back_soa_index = radeon_llvm_reg_index_soa( + ctx->r600_inputs[back_reg].gpr + , chan); + LLVMValueRef backcolor_reg = lp_build_const_int32( + ctx->soa.bld_base.base.gallivm, + back_soa_index); + LLVMValueRef backcolor = build_intrinsic( + ctx->soa.bld_base.base.gallivm->builder, + "llvm.R600.load.input", + ctx->soa.bld_base.base.elem_type, &backcolor_reg, 1, + LLVMReadNoneAttribute); + LLVMValueRef face_reg = lp_build_const_int32( + ctx->soa.bld_base.base.gallivm, + ctx->face_input * 4); + LLVMValueRef face = build_intrinsic( + ctx->soa.bld_base.base.gallivm->builder, + "llvm.R600.load.input", + ctx->soa.bld_base.base.elem_type, + &face_reg, 1, + LLVMReadNoneAttribute); + LLVMValueRef is_face_positive = LLVMBuildFCmp( + ctx->soa.bld_base.base.gallivm->builder, + LLVMRealUGT, face, + lp_build_const_float(ctx->soa.bld_base.base.gallivm, 0.0f), + ""); + ctx->inputs[soa_index] = LLVMBuildSelect( + ctx->soa.bld_base.base.gallivm->builder, + is_face_positive, + ctx->inputs[soa_index], + backcolor, + ""); + } } } diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 0c585de8263..daa50823448 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -1128,7 +1128,7 @@ static int tgsi_split_literal_constant(struct r600_shader_ctx *ctx) return 0; } -static int process_twoside_color_inputs(struct r600_shader_ctx *ctx) +static int process_twoside_color_inputs(struct r600_shader_ctx *ctx, unsigned use_llvm) { int i, r, count = ctx->shader->ninput; @@ -1139,9 +1139,12 @@ static int process_twoside_color_inputs(struct r600_shader_ctx *ctx) if ((r = evergreen_interp_input(ctx, back_facing_reg))) return r; } - r = select_twoside_color(ctx, i, back_facing_reg); - if (r) - return r; + + if (!use_llvm) { + r = select_twoside_color(ctx, i, back_facing_reg); + if (r) + return r; + } } } return 0; @@ -1402,7 +1405,7 @@ static int r600_shader_from_tgsi(struct r600_screen *rscreen, } if (shader->two_side && ctx.colors_used) { - if ((r = process_twoside_color_inputs(&ctx))) + if ((r = process_twoside_color_inputs(&ctx, use_llvm))) return r; } |