GS/HW: Improve clear detection with multiple Tris

This commit is contained in:
refractionpcsx2 2023-09-16 15:11:42 +01:00
parent fe79c0d294
commit 3dcc6dc299
2 changed files with 13 additions and 4 deletions

View File

@ -2755,16 +2755,24 @@ bool GSState::TrianglesAreQuads() const
{
const u16* const i = m_index.buff + idx;
// Make sure the next set of triangles matches an edge of the previous triangle.
if (idx > 0)
{
const u16* const prev_tri= m_index.buff + (idx - 3);
const GSVertex& vert = v[i[0]];
if (vert.XYZ != m_vertex.buff[prev_tri[0]].XYZ && vert.XYZ != m_vertex.buff[prev_tri[1]].XYZ && vert.XYZ != m_vertex.buff[prev_tri[2]].XYZ)
return false;
}
// Degenerate triangles should've been culled already, so we can check indices.
u32 extra_verts = 0;
for (u32 j = 3; j < 6; j++)
{
const u16 idx = i[j];
if (idx != i[0] && idx != i[1] && idx != i[2])
const u16 tri2_idx = i[j];
if (tri2_idx != i[0] && tri2_idx != i[1] && tri2_idx != i[2])
extra_verts++;
}
if (extra_verts == 1)
return true;
continue;
// As a fallback, they might've used different vertices with a tri list, not strip.
// Note that this won't work unless the quad is axis-aligned.

View File

@ -6222,7 +6222,7 @@ bool GSRendererHW::PrimitiveCoversWithoutGaps()
bool GSRendererHW::IsConstantDirectWriteMemClear()
{
const bool direct_draw = (m_vt.m_primclass == GS_SPRITE_CLASS) || (m_index.tail == 6 && m_vt.m_primclass == GS_TRIANGLE_CLASS);
const bool direct_draw = (m_vt.m_primclass == GS_SPRITE_CLASS) || (((m_index.tail % 6) == 0 && TrianglesAreQuads()) && m_vt.m_primclass == GS_TRIANGLE_CLASS);
// Constant Direct Write without texture/test/blending (aka a GS mem clear)
if (direct_draw && !PRIM->TME // Direct write
&& !(m_draw_env->SCANMSK.MSK & 2)
@ -6329,6 +6329,7 @@ void GSRendererHW::ReplaceVerticesWithSprite(const GSVector4i& unscaled_rect, co
m_r = unscaled_rect;
m_context->scissor.in = scissor;
m_vt.m_primclass = GS_SPRITE_CLASS;
}
void GSRendererHW::ReplaceVerticesWithSprite(const GSVector4i& unscaled_rect, const GSVector2i& unscaled_size)