diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 10b5e02412a..f6156a94cbc 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -4499,8 +4499,15 @@ LLVMValueRef ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef inte LLVMValueRef ac_build_load_helper_invocation(struct ac_llvm_context *ctx) { - LLVMValueRef result = - ac_build_intrinsic(ctx, "llvm.amdgcn.ps.live", ctx->i1, NULL, 0, AC_FUNC_ATTR_READNONE); + LLVMValueRef result; + + if (LLVM_VERSION_MAJOR >= 13) { + result = ac_build_intrinsic(ctx, "llvm.amdgcn.live.mask", ctx->i1, NULL, 0, + AC_FUNC_ATTR_READONLY | AC_FUNC_ATTR_INACCESSIBLE_MEM_ONLY); + } else { + result = ac_build_intrinsic(ctx, "llvm.amdgcn.ps.live", ctx->i1, NULL, 0, + AC_FUNC_ATTR_READNONE); + } return LLVMBuildNot(ctx->builder, result, ""); } @@ -4509,6 +4516,9 @@ LLVMValueRef ac_build_is_helper_invocation(struct ac_llvm_context *ctx) if (!ctx->postponed_kill) return ac_build_load_helper_invocation(ctx); + /* postponed_kill should be NULL on LLVM 13+ */ + assert(LLVM_VERSION_MAJOR < 13); + /* !(exact && postponed) */ LLVMValueRef exact = ac_build_intrinsic(ctx, "llvm.amdgcn.ps.live", ctx->i1, NULL, 0, AC_FUNC_ATTR_READNONE); diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 53e9bfaa1a3..fffe7664bd2 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -2865,6 +2865,12 @@ static void emit_demote(struct ac_nir_context *ctx, const nir_intrinsic_instr *i cond = ctx->ac.i1false; } + if (LLVM_VERSION_MAJOR >= 13) { + /* This demotes the pixel if the condition is false. */ + ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.wqm.demote", ctx->ac.voidt, &cond, 1, 0); + return; + } + LLVMValueRef mask = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, ""); mask = LLVMBuildAnd(ctx->ac.builder, mask, cond, ""); LLVMBuildStore(ctx->ac.builder, mask, ctx->ac.postponed_kill); @@ -5035,7 +5041,8 @@ void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi, if (gl_shader_stage_is_compute(nir->info.stage)) setup_shared(&ctx, nir); - if (nir->info.stage == MESA_SHADER_FRAGMENT && nir->info.fs.uses_demote) { + if (nir->info.stage == MESA_SHADER_FRAGMENT && nir->info.fs.uses_demote && + LLVM_VERSION_MAJOR < 13) { /* true = don't kill. */ ctx.ac.postponed_kill = ac_build_alloca_init(&ctx.ac, ctx.ac.i1true, ""); }