From a69afb68c9a54b475dd2f2588c6c54676b43f9dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Sun, 25 Jun 2017 17:56:37 +0200 Subject: [PATCH] radeonsi: use new function ac_build_umin for edgeflag clamping MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- 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 2dddf44ff85..9b939c148e5 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -908,6 +908,13 @@ ac_build_umsb(struct ac_llvm_context *ctx, 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) { diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index f25af8b76a8..09fd585706a 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -197,6 +197,7 @@ 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 { diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 2827b9d06a2..473dd95a149 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2502,7 +2502,7 @@ static void si_llvm_export_vs(struct lp_build_tgsi_context *bld_base, 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); -- 2.30.2