[Mesa-dev] [PATCH 2/2] radv/ac: emit isinf using ordered equal

Dave Airlie airlied at gmail.com
Fri Mar 17 00:04:32 UTC 2017


From: Dave Airlie <airlied at redhat.com>

This fixes:
dEQP-VK.glsl.builtin.function.common.isinf.*

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/amd/common/ac_nir_to_llvm.c | 14 ++++++++++++++
 src/amd/vulkan/radv_pipeline.c  |  1 +
 2 files changed, 15 insertions(+)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 2b41c51..15974a7 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1168,6 +1168,17 @@ static LLVMValueRef emit_ddxy(struct nir_to_llvm_context *ctx,
 	return result;
 }
 
+static LLVMValueRef emit_isinf(struct nir_to_llvm_context *ctx,
+			       nir_alu_instr *instr,
+			       LLVMValueRef src0)
+{
+	LLVMTypeRef def_type = get_def_type(ctx, &instr->dest.dest.ssa);
+	src0 = emit_intrin_1f_param(ctx, "llvm.fabs",
+				   to_float_type(ctx, def_type), src0);
+	src0 = emit_float_cmp(ctx, LLVMRealOEQ, src0, LLVMConstReal(ctx->f32, INFINITY));
+	return src0;
+}
+
 /*
  * this takes an I,J coordinate pair,
  * and works out the X and Y derivatives.
@@ -1534,6 +1545,9 @@ static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr)
 	case nir_op_fddy_coarse:
 		result = emit_ddxy(ctx, instr->op, src[0]);
 		break;
+	case nir_op_isinf:
+		result = emit_isinf(ctx, instr, src[0]);
+		break;
 	default:
 		fprintf(stderr, "Unknown NIR alu instr: ");
 		nir_print_instr(&instr->instr, stderr);
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index ce228df..cc15ef8 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -47,6 +47,7 @@ void radv_shader_variant_destroy(struct radv_device *device,
 static const struct nir_shader_compiler_options nir_options = {
 	.vertex_id_zero_based = true,
 	.lower_scmp = true,
+	.use_isinf = true,
 	.lower_flrp32 = true,
 	.lower_fsat = true,
 	.lower_pack_snorm_2x16 = true,
-- 
2.9.3



More information about the mesa-dev mailing list