mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 19:00:13 +01:00
r600g: use a select to handle front/back color in llvm
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
parent
80663cb185
commit
11e08f42e4
2 changed files with 44 additions and 5 deletions
|
|
@ -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,
|
||||
"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue