From b3c92cbb3b903b7500394fe8116ca5aa19cdfe77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 16 Oct 2026 01:21:04 +0200 Subject: [PATCH] GPU: Skip discarded AA lines like culled draws The hardware backends discard antialiased lines drawn with REPLACE (the heuristic from #6483 and #12588) by returning from Execute_Prim before the vertex or index pointer moves past them, and without taking their time. A game that draws on from where they end then reads the wrong vertices. Skip them like a culled draw instead, which does both, as the software renderer and the null GPU do. Co-Authored-By: Claude Opus 5.5 (1M context) --- GPU/GPUCommonHW.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index 13daa1cc7e..26e00da8ec 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -878,12 +878,10 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) { SetDrawType(DRAW_PRIM, prim); // Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though. - if (gstate.isAntiAliasEnabled()) { - // Heuristic derived from discussions in #6483 and #12588. - // Discard AA lines in Persona 3 Portable, DOA Paradise and Summon Night 5, while still keeping AA lines in Echochrome. - if ((prim == GE_PRIM_LINE_STRIP || prim == GE_PRIM_LINES) && gstate.getTextureFunction() == GE_TEXFUNC_REPLACE) - return; - } + // Heuristic derived from discussions in #6483 and #12588. + // Discard AA lines in Persona 3 Portable, DOA Paradise and Summon Night 5, while still keeping AA lines in Echochrome. + // They're skipped like culled draws, so the pointers still move past them and the time is still taken. + const bool discardLines = gstate.isAntiAliasEnabled() && (prim == GE_PRIM_LINE_STRIP || prim == GE_PRIM_LINES) && gstate.getTextureFunction() == GE_TEXFUNC_REPLACE; // Update cached framebuffer format. // We store it in the cache so it can be modified for blue-to-alpha, next. @@ -1012,11 +1010,11 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) { #endif // If certain conditions are true, do frustum culling. - bool passCulling = PASSES_CULLING; + bool passCulling = PASSES_CULLING && !discardLines; if (passCulling && !(flags & ClipInfoFlags::Valid)) { flags = DrawEngineCommon::UncheckedClipInfoFlags(); } - if (!passCulling) { + if (!passCulling && !discardLines) { // Do software culling. if (drawEngineCommon_->TestBoundingBoxFast(gstate_c.cullMatrix, verts, inds, count, decoder, vertexType, &flags)) { passCulling = true; @@ -1068,7 +1066,7 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) { case GE_CMD_PRIM: { GEPrimitiveType newPrim = static_cast((data >> 16) & 7); - if (IsTrianglePrim(newPrim) != isTriangle) + if (IsTrianglePrim(newPrim) != isTriangle || discardLines) goto bail; // Can't join over this boundary. Might as well exit and get this on the next time around. // TODO: more efficient updating of verts/inds