GS-hw: Cleanup GS memory clear.

Create IsConstantDirectWriteMemClear function to reduce code duplication and making code cleaner.
This commit is contained in:
lightningterror 2023-01-21 14:17:45 +01:00 committed by refractionpcsx2
parent 88c1f00b62
commit 9b1699a5a4
2 changed files with 18 additions and 18 deletions

View File

@ -1661,14 +1661,7 @@ void GSRendererHW::Draw()
if (!GSConfig.UserHacks_DisableSafeFeatures)
{
// Constant Direct Write without texture/test/blending (aka a GS mem clear)
if ((m_vt.m_primclass == GS_SPRITE_CLASS) && !PRIM->TME // Direct write
&& (!PRIM->ABE || IsOpaque() || m_context->ALPHA.IsCdOutput()) // No transparency
&& (m_context->FRAME.FBMSK == 0) // no color mask
&& !m_context->TEST.ATE // no alpha test
&& (!m_context->TEST.ZTE || m_context->TEST.ZTST == ZTST_ALWAYS) // no depth test
&& (m_vt.m_eq.rgba == 0xFFFF) // constant color write
&& m_r.x == 0 && m_r.y == 0) // Likely full buffer write
if (IsConstantDirectWriteMemClear())
{
// Likely doing a huge single page width clear, which never goes well. (Superman)
// Burnout 3 does a 32x1024 double width clear on its reflection targets.
@ -1813,17 +1806,8 @@ void GSRendererHW::Draw()
if (!GSConfig.UserHacks_DisableSafeFeatures)
{
// Constant Direct Write without texture/test/blending (aka a GS mem clear)
if ((m_vt.m_primclass == GS_SPRITE_CLASS) && !PRIM->TME // Direct write
&& (!PRIM->ABE || IsOpaque() || m_context->ALPHA.IsCdOutput()) // No transparency
&& (m_context->FRAME.FBMSK == 0) // no color mask
&& !m_context->TEST.ATE // no alpha test
&& (!m_context->TEST.ZTE || m_context->TEST.ZTST == ZTST_ALWAYS) // no depth test
&& (m_vt.m_eq.rgba == 0xFFFF) // constant color write
&& m_r.x == 0 && m_r.y == 0) // Likely full buffer write
{
if (IsConstantDirectWriteMemClear())
OI_DoubleHalfClear(rt, ds);
}
}
// A couple of hack to avoid upscaling issue. So far it seems to impacts mostly sprite
@ -4358,3 +4342,18 @@ bool GSRendererHW::OI_BlitFMV(GSTextureCache::Target* _rt, GSTextureCache::Sourc
// Nothing to see keep going
return true;
}
bool GSRendererHW::IsConstantDirectWriteMemClear()
{
// Constant Direct Write without texture/test/blending (aka a GS mem clear)
if ((m_vt.m_primclass == GS_SPRITE_CLASS) && !PRIM->TME // Direct write
&& (!PRIM->ABE || IsOpaque() || m_context->ALPHA.IsCdOutput()) // No transparency
&& (m_context->FRAME.FBMSK == 0) // no color mask
&& !m_context->TEST.ATE // no alpha test
&& (!m_context->TEST.ZTE || m_context->TEST.ZTST == ZTST_ALWAYS) // no depth test
&& (m_vt.m_eq.rgba == 0xFFFF) // constant color write
&& m_r.x == 0 && m_r.y == 0) // Likely full buffer write
return true;
return false;
}

View File

@ -65,6 +65,7 @@ private:
float alpha1(int L, int X0, int X1);
void SwSpriteRender();
bool CanUseSwSpriteRender();
bool IsConstantDirectWriteMemClear();
enum class CLUTDrawTestResult
{