[Mesa-dev] [PATCH 4/4] r600g: use a select to handle front/back color in llvm

Tom Stellard tom at stellard.net
Mon Sep 24 07:24:41 PDT 2012


On Mon, Sep 24, 2012 at 12:43:17AM +0200, Vincent Lejeune wrote:
> ---
>  src/gallium/drivers/r600/r600_llvm.c   | 36 ++++++++++++++++++++++++++++++++++
>  src/gallium/drivers/r600/r600_shader.c | 13 +++++++-----
>  2 files changed, 44 insertions(+), 5 deletions(-)
>

Same as patch 3, just make sure there are no TGSI compiler regressions.

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

> 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, &reg, 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
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list