Skip to content

Commit

Permalink
GS/HW: Fix pabe optimization condition.
Browse files Browse the repository at this point in the history
We should check only if As max is 128, also make sure we are checking the original Alpha C value as it could have been modified for an optimization.
  • Loading branch information
lightningterror committed Sep 15, 2024
1 parent 8d3f4fa commit ae0a1ac
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4431,13 +4431,12 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
if (m_draw_env->PABE.PABE && GetAlphaMinMax().min < 128)
{
// Breath of Fire Dragon Quarter, Strawberry Shortcake, Super Robot Wars, Cartoon Network Racing, Simple 2000 Series Vol.81, SOTC.
if (GetAlphaMinMax().max == 128 && m_conf.ps.blend_a == 0 && ((blend.dst == GSDevice::INV_SRC1_COLOR)
|| (blend.dst == GSDevice::INV_DST_ALPHA)
|| (blend.dst == GSDevice::INV_CONST_COLOR)))
// Alpha C could have been modified as an optimization so check the original value.
if (GetAlphaMinMax().max == 128 && m_conf.ps.blend_a == 0 && ALPHA.C == 0 && ((blend.dst == GSDevice::INV_SRC1_COLOR) || (blend.dst == GSDevice::INV_CONST_COLOR)))
{
// PABE disable blending:
// We can disable blending here as an optimization since alpha max is 128
// which if alpha is 1 in the formula Cs*Alpha + Cd*(1 - Alpha) will give us a result of Cs.
// which if alpha is 1 in the formula Cs*As + Cd*(1 - As) will give us a result of Cs.
m_conf.blend = {};
m_conf.ps.no_color1 = true;
m_conf.ps.blend_a = m_conf.ps.blend_b = m_conf.ps.blend_c = m_conf.ps.blend_d = 0;
Expand Down Expand Up @@ -4476,9 +4475,13 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
// PABE sw blend:
m_conf.ps.pabe = !(accumulation_blend || blend_mix);
}

GL_INS("PABE mode %s", m_conf.ps.pabe ? "ENABLED" : "DISABLED");
}

GL_INS("PABE mode %s", m_conf.ps.pabe ? "ENABLED" : "DISABLED");

// TODO: We can expand pabe hw to Cd*(1 - Alpha) where alpha is As or Af and replace the formula with Cs + 0 when As < 128,
// but need to find test cases where it makes a difference,
// C 12 Final Resistance triggers it but there's no difference and it's a psx game.
}

if (color_dest_blend)
Expand Down Expand Up @@ -4811,9 +4814,9 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo

if (m_conf.ps.blend_c == 2 && (m_conf.ps.blend_hw == static_cast<u8>(HWBlendType::SRC_ALPHA_DST_FACTOR)
|| m_conf.ps.blend_hw == static_cast<u8>(HWBlendType::SRC_HALF_ONE_DST_FACTOR)
|| m_conf.blend_multi_pass.blend_hw == static_cast<u8>(HWBlendType::SRC_ALPHA_DST_FACTOR)
|| m_conf.ps.blend_hw == static_cast<u8>(HWBlendType::SRC_INV_DST_BLEND_HALF)
|| m_conf.ps.blend_hw == static_cast<u8>(HWBlendType::INV_SRC_DST_BLEND_HALF)))
|| m_conf.ps.blend_hw == static_cast<u8>(HWBlendType::INV_SRC_DST_BLEND_HALF)
|| m_conf.blend_multi_pass.blend_hw == static_cast<u8>(HWBlendType::SRC_ALPHA_DST_FACTOR)))
{
m_conf.cb_ps.TA_MaxDepth_Af.a = static_cast<float>(AFIX) / 128.0f;
}
Expand Down

0 comments on commit ae0a1ac

Please sign in to comment.