From 1174ab6d56e779529a0ff1c01b78f49ce103eadf Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 16 Dec 2022 12:24:40 +0000 Subject: [PATCH] ac/llvm: use amdgpu-color-export/amdgpu-depth-export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are necessary to use the correct export target on GFX11: https://reviews.llvm.org/D128185 Fixes artifacts on Lara in Rise of the Tomb Raider benchmark and hair in The Witcher 3 (classic). Signed-off-by: Rhys Perry Reviewed-by: Marek Olšák Part-of: --- src/amd/llvm/ac_llvm_build.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 9a2b37efefc..ae2e18bed18 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -2028,6 +2028,15 @@ void ac_build_export(struct ac_llvm_context *ctx, struct ac_export_args *a) ac_build_intrinsic(ctx, "llvm.amdgcn.exp.f32", ctx->voidt, args, 8, 0); } + + if (LLVM_VERSION_MAJOR >= 15 && a->target == V_008DFC_SQ_EXP_MRTZ) { + LLVMAddTargetDependentFunctionAttr(ctx->main_function.value, "amdgpu-depth-export", "1"); + } else if (LLVM_VERSION_MAJOR >= 15 && a->target <= V_008DFC_SQ_EXP_NULL) { + /* We need this attribute even for NULL targets, so that an export is created for full-wave + * discards on GFX10+. + */ + LLVMAddTargetDependentFunctionAttr(ctx->main_function.value, "amdgpu-color-export", "1"); + } } void ac_build_export_null(struct ac_llvm_context *ctx, bool uses_discard) @@ -4619,6 +4628,12 @@ struct ac_llvm_pointer ac_build_main(const struct ac_shader_args *args, struct a /* Disable denormals for FP32: */ LLVMAddTargetDependentFunctionAttr(main_function, "denormal-fp-math-f32", "preserve-sign,preserve-sign"); + + if (LLVM_VERSION_MAJOR >= 15 && convention == AC_LLVM_AMDGPU_PS) { + LLVMAddTargetDependentFunctionAttr(main_function, "amdgpu-depth-export", "0"); + LLVMAddTargetDependentFunctionAttr(main_function, "amdgpu-color-export", "0"); + } + return ctx->main_function; }