radeonsi: postponed KILL isn't postponed anymore, but maintains WQM
authorMarek Olšák <marek.olsak@amd.com>
Wed, 4 Oct 2017 03:07:50 +0000 (05:07 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 24 Oct 2017 12:56:34 +0000 (14:56 +0200)
This restores performance for the drirc workaround, i.e.
KILL_IF does:
   visible = src0 >= 0;
   kill_flag &= visible; // accumulate kills
   amdgcn_kill(wqm_vote(visible)); // kill fully dead quads only

And all helper pixels are killed at the end of the shader:
   amdgcn_kill(kill_flag);

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c

index 3e5b795d6fecb29e9b29178d5cf9f209600c4e18..80b027e8b0803e4cc8b6eb5ebf5cc5ee2dd879f3 100644 (file)
@@ -1405,6 +1405,13 @@ LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx,
                                  AC_FUNC_ATTR_LEGACY);
 }
 
+LLVMValueRef ac_build_wqm_vote(struct ac_llvm_context *ctx, LLVMValueRef i1)
+{
+       assert(HAVE_LLVM >= 0x0600);
+       return ac_build_intrinsic(ctx, "llvm.amdgcn.wqm.vote", ctx->i1,
+                                 &i1, 1, AC_FUNC_ATTR_READNONE);
+}
+
 void ac_build_kill_if_false(struct ac_llvm_context *ctx, LLVMValueRef i1)
 {
        if (HAVE_LLVM >= 0x0600) {
index 8f7a9abb76cd1bee530a90f485b37e9865ac4500..996f55862baa0d98414a3da9d3d7e371208252c1 100644 (file)
@@ -265,6 +265,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
                                   struct ac_image_args *a);
 LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx,
                                    LLVMValueRef args[2]);
+LLVMValueRef ac_build_wqm_vote(struct ac_llvm_context *ctx, LLVMValueRef i1);
 void ac_build_kill_if_false(struct ac_llvm_context *ctx, LLVMValueRef i1);
 LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input,
                          LLVMValueRef offset, LLVMValueRef width,
index 283a889d84739fa7eec3993bd5a957bf155fbd29..913b6c329597ab0f210a1fe5f80b5dc99848ac1c 100644 (file)
@@ -69,6 +69,12 @@ static void kil_emit(const struct lp_build_tgsi_action *action,
        }
 
        if (ctx->shader->selector->force_correct_derivs_after_kill) {
+               /* LLVM 6.0 can kill immediately while maintaining WQM. */
+               if (HAVE_LLVM >= 0x0600) {
+                       ac_build_kill_if_false(&ctx->ac,
+                                              ac_build_wqm_vote(&ctx->ac, visible));
+               }
+
                LLVMValueRef mask = LLVMBuildLoad(builder, ctx->postponed_kill, "");
                mask = LLVMBuildAnd(builder, mask, visible, "");
                LLVMBuildStore(builder, mask, ctx->postponed_kill);