[Mesa-dev] [PATCH v2 63/73] radeonsi: use new function ac_build_umin for edgeflag clamping

Nicolai Hähnle nhaehnle at gmail.com
Wed Jul 5 10:48:47 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/amd/common/ac_llvm_build.c           | 7 +++++++
 src/amd/common/ac_llvm_build.h           | 1 +
 src/gallium/drivers/radeonsi/si_shader.c | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 2dddf44..9b939c1 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -901,20 +901,27 @@ ac_build_umsb(struct ac_llvm_context *ctx,
 	msb = LLVMBuildSub(ctx->builder, LLVMConstInt(ctx->i32, 31, false),
 			   msb, "");
 
 	/* check for zero */
 	return LLVMBuildSelect(ctx->builder,
 			       LLVMBuildICmp(ctx->builder, LLVMIntEQ, arg,
 					     LLVMConstInt(ctx->i32, 0, 0), ""),
 			       LLVMConstInt(ctx->i32, -1, true), msb, "");
 }
 
+LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a,
+			   LLVMValueRef b)
+{
+	LLVMValueRef cmp = LLVMBuildICmp(ctx->builder, LLVMIntULE, a, b, "");
+	return LLVMBuildSelect(ctx->builder, cmp, a, b, "");
+}
+
 LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value)
 {
 	if (HAVE_LLVM >= 0x0500) {
 		LLVMValueRef max[2] = {
 			value,
 			LLVMConstReal(ctx->f32, 0),
 		};
 		LLVMValueRef min[2] = {
 			LLVMConstReal(ctx->f32, 1),
 		};
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index f25af8b..09fd585 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -190,20 +190,21 @@ void ac_build_sendmsg(struct ac_llvm_context *ctx,
 		      LLVMValueRef wave_id);
 
 LLVMValueRef ac_build_imsb(struct ac_llvm_context *ctx,
 			   LLVMValueRef arg,
 			   LLVMTypeRef dst_type);
 
 LLVMValueRef ac_build_umsb(struct ac_llvm_context *ctx,
 			  LLVMValueRef arg,
 			  LLVMTypeRef dst_type);
 
+LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
 LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value);
 
 struct ac_export_args {
 	LLVMValueRef out[4];
         unsigned target;
         unsigned enabled_channels;
         bool compr;
         bool done;
         bool valid_mask;
 };
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 96fce0e..71e559f 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2502,21 +2502,21 @@ handle_semantic:
 
 		if (shader->selector->info.writes_psize)
 			pos_args[1].out[0] = psize_value;
 
 		if (shader->selector->info.writes_edgeflag) {
 			/* The output is a float, but the hw expects an integer
 			 * with the first bit containing the edge flag. */
 			edgeflag_value = LLVMBuildFPToUI(ctx->gallivm.builder,
 							 edgeflag_value,
 							 ctx->i32, "");
-			edgeflag_value = lp_build_min(&bld_base->int_bld,
+			edgeflag_value = ac_build_umin(&ctx->ac,
 						      edgeflag_value,
 						      ctx->i32_1);
 
 			/* The LLVM intrinsic expects a float. */
 			pos_args[1].out[1] = LLVMBuildBitCast(ctx->gallivm.builder,
 							  edgeflag_value,
 							  ctx->f32, "");
 		}
 
 		if (ctx->screen->b.chip_class >= GFX9) {
-- 
2.9.3



More information about the mesa-dev mailing list