Skip to content

Commit

Permalink
GS/HW: Wip Zero blend RT.
Browse files Browse the repository at this point in the history
  • Loading branch information
lightningterror committed Sep 15, 2024
1 parent 2b7c4ae commit 9d34e38
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4098,6 +4098,16 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
GL_INS("Draw AlphaMinMax: %d-%d, RT AlphaMinMax: %d-%d, AFIX: %u", GetAlphaMinMax().min, GetAlphaMinMax().max, rt_alpha_min, rt_alpha_max, AFIX);
#endif

if (rt->m_dirty.empty() && rt->m_rt_rgb_zero)
{
m_conf.ps.blend_a = 0;
m_conf.ps.blend_b = 0;
m_conf.ps.blend_c = 0;
m_conf.ps.blend_d = 2;

rt->m_rt_rgb_zero = false;
}

// If the colour is modulated to zero or we're not using a texture and the color is zero, we can replace any Cs with 0
if ((!PRIM->TME || m_cached_ctx.TEX0.TFX != TFX_DECAL) && (!PRIM->FGE || m_draw_env->FOGCOL.U32[0] == 0) &&
((m_vt.m_max.c == GSVector4i::zero()).mask() & 0xfff) == 0xfff)
Expand Down Expand Up @@ -4201,6 +4211,11 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
m_conf.ps.blend_d = 2;
}

if (rt->m_dirty.empty() && (m_conf.ps.blend_a == m_conf.ps.blend_b) && m_conf.ps.blend_d == 2)
{
rt->m_rt_rgb_zero = true;
}

// Ad cases, alpha write is masked, one barrier is enough, for d3d11 read the fb
// Replace Ad with As, blend flags will be used from As since we are chaging the blend_index value.
// Must be done before index calculation, after blending equation optimizations
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GS/Renderers/HW/GSTextureCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class GSTextureCache
bool m_valid_alpha_high = false;
bool m_valid_rgb = false;
bool m_rt_alpha_scale = false;
bool m_rt_rgb_zero = false;
bool m_downscaled = false;
int m_last_draw = 0;

Expand Down

0 comments on commit 9d34e38

Please sign in to comment.