From 71b6d40d08efce34c93bc5b45e34de98037f30e9 Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:55:50 +0200 Subject: [PATCH] GS/HW: Wip Zero blend RT. --- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 17 +++++++++++++++++ pcsx2/GS/Renderers/HW/GSTextureCache.h | 1 + 2 files changed, 18 insertions(+) diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 86d8f143d9..be48bd30d0 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -4098,6 +4098,18 @@ 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) + { + if (m_conf.ps.blend_a == 1) + m_conf.ps.blend_a = 2; + if (m_conf.ps.blend_b == 1) + m_conf.ps.blend_b = 2; + if (m_conf.ps.blend_d == 1) + 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) @@ -4201,6 +4213,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 diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.h b/pcsx2/GS/Renderers/HW/GSTextureCache.h index c2551f4b39..f994b7bd94 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.h +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.h @@ -220,6 +220,7 @@ public: 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;