[Mesa-dev] [PATCH 1/3] ac/nir: add support for discard_if intrinsic (v2)
Dave Airlie
airlied at gmail.com
Tue Nov 8 06:56:28 UTC 2016
From: Dave Airlie <airlied at redhat.com>
We are going to start lowering to this in NIR code,
so prepare radv for it.
v2: handle conversion to kilp properly (nha)
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/amd/common/ac_nir_to_llvm.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index ae0ede6..c8ee784 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2614,6 +2614,24 @@ static void emit_barrier(struct nir_to_llvm_context *ctx)
ctx->voidt, NULL, 0, 0);
}
+static void emit_discard_if(struct nir_to_llvm_context *ctx,
+ nir_intrinsic_instr *instr)
+{
+ LLVMValueRef cond;
+ ctx->shader_info->fs.can_discard = true;
+
+ cond = LLVMBuildICmp(ctx->builder, LLVMIntNE,
+ get_src(ctx, instr->src[0]),
+ ctx->i32zero, "");
+
+ cond = LLVMBuildSelect(ctx->builder, cond,
+ LLVMConstReal(ctx->f32, -1.0f),
+ ctx->f32zero, "");
+ emit_llvm_intrinsic(ctx, "llvm.AMDGPU.kill",
+ LLVMVoidTypeInContext(ctx->context),
+ &cond, 1, 0);
+}
+
static LLVMValueRef
visit_load_local_invocation_index(struct nir_to_llvm_context *ctx)
{
@@ -2926,6 +2944,9 @@ static void visit_intrinsic(struct nir_to_llvm_context *ctx,
LLVMVoidTypeInContext(ctx->context),
NULL, 0, 0);
break;
+ case nir_intrinsic_discard_if:
+ emit_discard_if(ctx, instr);
+ break;
case nir_intrinsic_memory_barrier:
emit_waitcnt(ctx);
break;
--
2.5.5
More information about the mesa-dev
mailing list