From 1352f0ba50132a761ffd3d89f47be65c09abe399 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sun, 21 Dec 2025 21:11:59 -0600 Subject: [PATCH] chore(gx): minor clarity improvements in BATCHEDRENDERFONTDESC::RenderBatch --- src/gx/font/CGxStringBatch.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gx/font/CGxStringBatch.cpp b/src/gx/font/CGxStringBatch.cpp index 3ba0c5d..5e9b90f 100644 --- a/src/gx/font/CGxStringBatch.cpp +++ b/src/gx/font/CGxStringBatch.cpp @@ -173,23 +173,26 @@ void BATCHEDRENDERFONTDESC::RenderBatch() { int32_t sliceOffset = 0; while (vertsNeeded) { + // Clamp slice vertex count to remaining batch capacity int32_t sliceCount = std::min(vertsNeeded, batchCapacity); + // Write string vertices within slice to buffer string->WriteGeometry(vertexBuf, lineIndex, sliceOffset, sliceCount); vertsNeeded -= sliceCount; - sliceOffset += sliceCount; batchCapacity -= sliceCount; + sliceOffset += sliceCount; vertexBuf += sliceCount; - if (!batchCapacity) { + // Render full buffer and reset capacity + if (batchCapacity == 0) { vertexBuf = this->UnlockVertexPtrAndRender(vertexStream, maxBatchCapacity); batchCapacity = maxBatchCapacity; } } } - // Render used portion of buffer and reset + // Render used portion of buffer and reset capacity if (batchCapacity != maxBatchCapacity) { vertexBuf = this->UnlockVertexPtrAndRender(vertexStream, maxBatchCapacity - batchCapacity); batchCapacity = maxBatchCapacity;