From fdb9d41d33a75815b46ca33f8d2e90f6e055883f Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:02:54 +0200 Subject: [PATCH] GS/HW: Adjust when blend second pass is enabled. If texture barriers are supported don't enable it at all. Remove blend second pass from Metal, no need as texture copies are always enabled. --- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 14 +++++++------- pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm | 9 --------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index a593f0f25a77f9..71f7e81b35f36d 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -4017,13 +4017,13 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT const bool no_prim_overlap = (m_prim_overlap == PRIM_OVERLAP_NO); // HW blend can be done in multiple passes when there's no overlap. - // Render passes are faster than copies so what we can do is trade the same number - // of copies that would've been used for SW blend for the same number of draw calls instead. - // It is a middle ground between accuracy and speed, higher blend levels will still prefer sw blend. - //const bool bmix1_second_pass_1 = no_prim_overlap && blend_mix1 && m_conf.ps.blend_a == m_conf.ps.blend_d; - const bool bmix1_second_pass = no_prim_overlap && blend_mix1 && (alpha_c0_high_max_one || alpha_c1_high_max_one || alpha_c2_high_one) && m_conf.ps.blend_d == 2; + // Blend second pass is only useful when texture barriers aren't supported. + // Speed wise Texture barriers > blend second pass > texture copies. + // TODO: 24bit and 32bit formats on clamp 1 can always prefer blend second pass depending on the blend equations. + const bool blend_second_pass_support = !features.texture_barrier && no_prim_overlap && is_basic_blend; + const bool bmix1_second_pass = blend_second_pass_support && blend_mix1 && (alpha_c0_high_max_one || alpha_c2_high_one) && m_conf.ps.blend_d == 2; // We don't want to enable blend mix if we are doing a second pass, it's useless. - blend_mix &= !bmix1_second_pass; + blend_mix &= !bmix1_second_pass; const bool one_barrier = m_conf.require_one_barrier || blend_ad_alpha_masked; // Condition 1: Require full sw blend for full barrier. @@ -4399,7 +4399,7 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT { m_conf.ps.blend_hw = 3; } - else if (is_basic_blend && no_prim_overlap) + else if (blend_second_pass_support) { const HWBlend blend_second_pass = GSDevice::GetBlend(blend_index); if ((alpha_c0_high_max_one || alpha_c2_high_one) && (blend_flag & BLEND_HW4)) diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm index 43bd8480875bf5..b9240682c1e3fd 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -2213,15 +2213,6 @@ static bool usesStencil(GSHWDrawConfig::DestinationAlphaMode dstalpha) SendHWDraw(config, mtlenc, index_buffer, index_buffer_offset); - if (config.blend_second_pass.enable) - { - if (config.blend_second_pass.blend.constant_enable) - MRESetBlendColor(config.blend_second_pass.blend.constant); - config.ps.blend_hw = config.blend_second_pass.blend_hw; - MRESetHWPipelineState(config.vs, config.ps, config.blend_second_pass.blend, config.colormask); - SendHWDraw(config, mtlenc, index_buffer, index_buffer_offset); - } - if (config.alpha_second_pass.enable) { if (config.alpha_second_pass.ps_aref != config.cb_ps.FogColor_AREF.a)