From: Rhys Perry Date: Thu, 15 Dec 2022 20:31:52 +0000 (+0000) Subject: aco/gfx11: export mrtz in discard early exit for non-color shaders X-Git-Tag: upstream/23.3.3~15455 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=192486b7aa5ef3b24516e16b0e219fad7032fb7c;p=platform%2Fupstream%2Fmesa.git aco/gfx11: export mrtz in discard early exit for non-color shaders If a shader doesn't export any color targets and instead only exports mrtz, the discard early exit block should match. Fixes artifacts on Lara in Rise of the Tomb Raider benchmark and hair in The Witcher 3 (classic). https://reviews.llvm.org/D128185 Signed-off-by: Rhys Perry Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Samuel Pitoiset Fixes: bc8da20dda6 ("aco: export MRT0 instead of NULL on GFX11") Part-of: --- diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index b9df226..e8808e4 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -11198,6 +11198,8 @@ export_mrt(isel_context* ctx, const struct aco_export_mrt* mrt) bld.exp(aco_opcode::exp, mrt->out[0], mrt->out[1], mrt->out[2], mrt->out[3], mrt->enabled_channels, mrt->target, mrt->compr); + + ctx->program->has_color_exports = true; } static bool @@ -11392,6 +11394,8 @@ create_fs_null_export(isel_context* ctx) unsigned dest = ctx->options->gfx_level >= GFX11 ? V_008DFC_SQ_EXP_MRT : V_008DFC_SQ_EXP_NULL; bld.exp(aco_opcode::exp, Operand(v1), Operand(v1), Operand(v1), Operand(v1), /* enabled_mask */ 0, dest, /* compr */ false, /* done */ true, /* vm */ true); + + ctx->program->has_color_exports = true; } static void @@ -11467,6 +11471,8 @@ create_fs_dual_src_export_gfx11(isel_context* ctx, const struct aco_export_mrt* exp->definitions[4] = bld.def(bld.lm, vcc); exp->definitions[5] = bld.def(s1, scc); ctx->block->instructions.emplace_back(std::move(exp)); + + ctx->program->has_color_exports = true; } static void diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 583857f..7d9a34b 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -2156,6 +2156,7 @@ public: Stage stage; bool needs_exact = false; /* there exists an instruction with disable_wqm = true */ bool needs_wqm = false; /* there exists a p_wqm instruction */ + bool has_color_exports = false; std::vector constant_data; Temp private_segment_buffer; diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp index a0a746f..ccd53b2 100644 --- a/src/amd/compiler/aco_lower_to_hw_instr.cpp +++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp @@ -2198,9 +2198,12 @@ lower_to_hw_instr(Program* program) block = &program->blocks[block_idx]; bld.reset(discard_block); + unsigned target = V_008DFC_SQ_EXP_NULL; + if (program->gfx_level >= GFX11) + target = + program->has_color_exports ? V_008DFC_SQ_EXP_MRT : V_008DFC_SQ_EXP_MRTZ; bld.exp(aco_opcode::exp, Operand(v1), Operand(v1), Operand(v1), Operand(v1), 0, - program->gfx_level >= GFX11 ? V_008DFC_SQ_EXP_MRT : V_008DFC_SQ_EXP_NULL, - false, true, true); + target, false, true, true); if (should_dealloc_vgprs) bld.sopp(aco_opcode::s_sendmsg, -1, sendmsg_dealloc_vgprs); bld.sopp(aco_opcode::s_endpgm);