GS: Move force_a_one to IsCoverageAlpha function

This commit is contained in:
refractionpcsx2 2022-07-18 02:20:08 +01:00
parent c2bb936586
commit ed76e54904
3 changed files with 13 additions and 11 deletions

View File

@ -3747,6 +3747,11 @@ bool GSState::IsMipMapActive()
return m_mipmap && IsMipMapDraw(); return m_mipmap && IsMipMapDraw();
} }
bool GSState::IsCoverageAlpha()
{
return !PRIM->ABE && PRIM->AA1 && (m_vt.m_primclass == GS_LINE_CLASS || m_vt.m_primclass == GS_TRIANGLE_CLASS);
}
GIFRegTEX0 GSState::GetTex0Layer(u32 lod) GIFRegTEX0 GSState::GetTex0Layer(u32 lod)
{ {
// Shortcut // Shortcut

View File

@ -217,6 +217,7 @@ protected:
bool IsOpaque(); bool IsOpaque();
bool IsMipMapDraw(); bool IsMipMapDraw();
bool IsMipMapActive(); bool IsMipMapActive();
bool IsCoverageAlpha();
public: public:
GIFPath m_path[4]; GIFPath m_path[4];

View File

@ -1277,11 +1277,9 @@ void GSRendererHW::Draw()
// Test if we can optimize Alpha Test as a NOP // Test if we can optimize Alpha Test as a NOP
context->TEST.ATE = context->TEST.ATE && !GSRenderer::TryAlphaTest(fm, fm_mask, zm); context->TEST.ATE = context->TEST.ATE && !GSRenderer::TryAlphaTest(fm, fm_mask, zm);
const bool force_a_one = !PRIM->ABE && PRIM->AA1 && (m_vt.m_primclass == GS_LINE_CLASS || m_vt.m_primclass == GS_TRIANGLE_CLASS);
// Need to fix the alpha test, since the alpha will be fixed to 1.0 if ABE is disabled and AA1 is enabled // Need to fix the alpha test, since the alpha will be fixed to 1.0 if ABE is disabled and AA1 is enabled
// So if it doesn't meet the condition, always fail, if it does, always pass (turn off the test). // So if it doesn't meet the condition, always fail, if it does, always pass (turn off the test).
if (force_a_one && context->TEST.ATE && context->TEST.ATST > 1) if (IsCoverageAlpha() && context->TEST.ATE && context->TEST.ATST > 1)
{ {
const float aref = (float)context->TEST.AREF; const float aref = (float)context->TEST.AREF;
const int old_ATST = context->TEST.ATST; const int old_ATST = context->TEST.ATST;
@ -2402,17 +2400,16 @@ void GSRendererHW::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER, bool&
// When AA1 is enabled and Alpha Blending is disabled, alpha blending done with coverage instead of alpha. // When AA1 is enabled and Alpha Blending is disabled, alpha blending done with coverage instead of alpha.
// We use a COV value of 128 (full coverage) in triangles (except the edge geometry, which we can't do easily). // We use a COV value of 128 (full coverage) in triangles (except the edge geometry, which we can't do easily).
const bool force_a_one = !PRIM->ABE && AA1; if (IsCoverageAlpha())
if (force_a_one)
{ {
m_conf.ps.fixed_one_a = 1; m_conf.ps.fixed_one_a = 1;
m_conf.ps.blend_c = 0; m_conf.ps.blend_c = 0;
} }
// Get alpha value // Get alpha value
const bool alpha_c0_zero = (m_conf.ps.blend_c == 0 && GetAlphaMinMax().max == 0) && !force_a_one; const bool alpha_c0_zero = (m_conf.ps.blend_c == 0 && GetAlphaMinMax().max == 0) && !IsCoverageAlpha();
const bool alpha_c0_one = (m_conf.ps.blend_c == 0 && (GetAlphaMinMax().min == 128) && (GetAlphaMinMax().max == 128)) || force_a_one; const bool alpha_c0_one = (m_conf.ps.blend_c == 0 && (GetAlphaMinMax().min == 128) && (GetAlphaMinMax().max == 128)) || IsCoverageAlpha();
const bool alpha_c0_high_max_one = (m_conf.ps.blend_c == 0 && GetAlphaMinMax().max > 128) && !force_a_one; const bool alpha_c0_high_max_one = (m_conf.ps.blend_c == 0 && GetAlphaMinMax().max > 128) && !IsCoverageAlpha();
const bool alpha_c2_zero = (m_conf.ps.blend_c == 2 && ALPHA.FIX == 0u); const bool alpha_c2_zero = (m_conf.ps.blend_c == 2 && ALPHA.FIX == 0u);
const bool alpha_c2_one = (m_conf.ps.blend_c == 2 && ALPHA.FIX == 128u); const bool alpha_c2_one = (m_conf.ps.blend_c == 2 && ALPHA.FIX == 128u);
const bool alpha_c2_high_one = (m_conf.ps.blend_c == 2 && ALPHA.FIX > 128u); const bool alpha_c2_high_one = (m_conf.ps.blend_c == 2 && ALPHA.FIX > 128u);
@ -3284,8 +3281,6 @@ void GSRendererHW::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc
// DATE: selection of the algorithm. Must be done before blending because GL42 is not compatible with blending // DATE: selection of the algorithm. Must be done before blending because GL42 is not compatible with blending
if (DATE) if (DATE)
{ {
// When Blending is disabled and Edge Anti Aliasing is enabled, the output alpha is Coverage (which we force to 128) so DATE will fail/pass guaranteed on second pass.
const bool force_a_one = !PRIM->ABE && PRIM->AA1 && (m_vt.m_primclass == GS_LINE_CLASS || m_vt.m_primclass == GS_TRIANGLE_CLASS);
// It is way too complex to emulate texture shuffle with DATE, so use accurate path. // It is way too complex to emulate texture shuffle with DATE, so use accurate path.
// No overlap should be triggered on gl/vk only as they support DATE_BARRIER. // No overlap should be triggered on gl/vk only as they support DATE_BARRIER.
if (features.framebuffer_fetch) if (features.framebuffer_fetch)
@ -3303,7 +3298,8 @@ void GSRendererHW::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc
DATE_BARRIER = true; DATE_BARRIER = true;
} }
} }
else if (m_conf.colormask.wa && (m_context->FBA.FBA || force_a_one)) // When Blending is disabled and Edge Anti Aliasing is enabled, the output alpha is Coverage (which we force to 128) so DATE will fail/pass guaranteed on second pass.
else if (m_conf.colormask.wa && (m_context->FBA.FBA || IsCoverageAlpha()))
{ {
GL_PERF("DATE: Fast with FBA, all pixels will be >= 128"); GL_PERF("DATE: Fast with FBA, all pixels will be >= 128");
DATE_one = !m_context->TEST.DATM; DATE_one = !m_context->TEST.DATM;