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 13, 2024
1 parent 0cf4b76 commit 8bab485
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4424,13 +4424,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 (ALPHA.C == 0 && GetAlphaMinMax().max == 128 && m_conf.ps.blend_a == 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 @@ -4804,9 +4803,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 8bab485

Please sign in to comment.