[Mesa-dev] [PATCH 4/4] r600g: use a select to handle front/back color in llvm
Vincent Lejeune
vljn at ovi.com
Sun Sep 23 15:43:17 PDT 2012
---
src/gallium/drivers/r600/r600_llvm.c | 36 ++++++++++++++++++++++++++++++++++
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 e77758b..a82d3b6 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->tgsi_inputs.r600_inputs[input_index]
+ .potential_back_facing_reg;
+ unsigned back_soa_index = radeon_llvm_reg_index_soa(
+ ctx->tgsi_inputs.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 310ab62..86ac7ec 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -1119,7 +1119,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;
@@ -1130,9 +1130,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;
@@ -1392,7 +1395,7 @@ static int r600_shader_from_tgsi(struct r600_context * rctx, struct r600_pipe_sh
}
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;
}
--
1.7.11.4
More information about the mesa-dev
mailing list