Skip to content

Commit

Permalink
GS/HW: Adjust when blend second pass is enabled.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lightningterror committed Apr 1, 2024
1 parent a4af461 commit 9f455a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
15 changes: 8 additions & 7 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -4399,7 +4399,8 @@ 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)

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))
Expand Down
9 changes: 0 additions & 9 deletions pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9f455a0

Please sign in to comment.