From fc349bd0b8e9df5fb1e28f142b49fd0851c4fdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 31 Aug 2026 15:46:00 +0200 Subject: [PATCH] ExtendNonIndexedPrim: round triangle counts down like SubmitPrim does SubmitPrim rounds a GE_PRIM_TRIANGLES vertex count down to a multiple of 3 (issue #7503) after having already set bytesRead from the full count. The extend path skipped the rounding entirely, so a 4-vertex triangle prim taken this way emitted two triangles instead of one. Round the index count and keep advancing the vertex offset by the full count, matching the order SubmitPrim does it in. --- GPU/Common/DrawEngineCommon.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 4ddcf8d326..067b83a3d9 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -755,14 +755,23 @@ int DrawEngineCommon::ExtendNonIndexedPrim(const uint32_t *cmd, const uint32_t * if (numDrawInds >= MAX_DEFERRED_DRAW_INDS || vertexCountInDrawCalls_ + offset + vertexCount > VERTEX_BUFFER_MAX) { break; } - DeferredInds &di = drawInds_[numDrawInds++]; - di.indexType = 0; - di.prim = newPrim; - seenPrims |= (1 << newPrim); - di.clockwise = clockwise; - di.vertexCount = vertexCount; - di.vertDecodeIndex = prevDrawVerts; - di.offset = offset; + // SubmitPrim rounds a GE_PRIM_TRIANGLES count down to a multiple of 3 (issue #7503) after + // having already counted the full vertex data, so do both here too - otherwise a 4-vertex + // triangle prim taking this path emits two triangles instead of one. + int indexCount = vertexCount; + if (newPrim == GE_PRIM_TRIANGLES) { + indexCount -= indexCount % 3; + } + if (indexCount > 0) { + DeferredInds &di = drawInds_[numDrawInds++]; + di.indexType = 0; + di.prim = newPrim; + seenPrims |= (1 << newPrim); + di.clockwise = clockwise; + di.vertexCount = indexCount; + di.vertDecodeIndex = prevDrawVerts; + di.offset = offset; + } offset += vertexCount; cmd++; }