ac: add support for gl_HelperInvocation
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 18 Jan 2018 23:04:26 +0000 (10:04 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 22 Jan 2018 22:23:26 +0000 (09:23 +1100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/amd/common/ac_nir_to_llvm.c

index 1e592db57a84f575f7745721e4a248b75294ff24..b90c31320c01f2780239e5fabc30dfeb5e5fb94d 100644 (file)
@@ -3915,6 +3915,17 @@ static void emit_discard(struct ac_nir_context *ctx,
        ac_build_kill_if_false(&ctx->ac, cond);
 }
 
+static LLVMValueRef
+visit_load_helper_invocation(struct ac_nir_context *ctx)
+{
+       LLVMValueRef result = ac_build_intrinsic(&ctx->ac,
+                                                "llvm.amdgcn.ps.live",
+                                                ctx->ac.i1, NULL, 0,
+                                                AC_FUNC_ATTR_READNONE);
+       result = LLVMBuildNot(ctx->ac.builder, result, "");
+       return LLVMBuildSExt(ctx->ac.builder, result, ctx->ac.i32, "");
+}
+
 static LLVMValueRef
 visit_load_local_invocation_index(struct nir_to_llvm_context *ctx)
 {
@@ -4354,6 +4365,9 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
        case nir_intrinsic_load_front_face:
                result = ctx->abi->front_face;
                break;
+       case nir_intrinsic_load_helper_invocation:
+               result = visit_load_helper_invocation(ctx);
+               break;
        case nir_intrinsic_load_instance_id:
                result = ctx->abi->instance_id;
                break;