Skip to content

Fix the reuse check of the 32-bit quad indexes - #1385

Merged
TothBenoit merged 1 commit into
HeapsIO:masterfrom
Simn:fix-quad-indexes-reuse
Nov 9, 2026
Merged

TothBenoit merged 1 commit into
HeapsIO:masterfrom
Simn:fix-quad-indexes-reuse

Conversation

@Simn

@Simn Simn commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

MemoryManager.getQuadIndexes decides whether the existing 32-bit quad indexes are large enough by comparing their index count with the vertex count:

if( quadIndexes32 == null || quadIndexes32.count < vertices ) {

but a quad needs 6 indexes for 4 vertices, and the number of indexes needed is already computed as nquads. So the check passes when it shouldn't. For example:

  1. A quad buffer of 65536 vertices is drawn: indexes are built for sz = 131072 indexes, i.e. 21845 quads.
  2. A buffer of 131072 vertices (32768 quads) is drawn: 131072 < 131072 is false, so those indexes are kept.
  3. renderQuadBuffer with more than 21845 quads then reads past the index data, and the quads beyond it aren't drawn, without any error.

The fix compares with nquads. Triangle indexes (getTriIndexes) use one index per vertex, so their check is correct.

Tested with DirectX 11: drawing 15000, then 22000, then 40000 quads from one growing Dynamic buffer through renderQuadBuffer; without the fix the last quads of the 22000 aren't drawn, with it all are.

🤖 Generated with Claude Code

getQuadIndexes compared the existing buffer's index count with the vertex
count instead of the index count it needs (nquads, 6 per quad). After a
buffer grew from 65536 to 131072 vertices, the indexes built for the
smaller one (21845 quads) were kept, and quads beyond them weren't drawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TothBenoit
TothBenoit merged commit ca3cc38 into HeapsIO:master Nov 9, 2026
2 checks passed
@Simn
Simn deleted the fix-quad-indexes-reuse branch November 9, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants