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.
This commit is contained in:
Henrik Rydgård committed 2026-08-31 15:46:00 +02:00
1 parent 3470c0e000
commit fc349bd0b8
1 file changed
+17 -8
+17 -8
View File
@@ -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++;
}