Skip to content

perf: shrink the GPU vertex buffer to 1M vertices - #24

Merged
jackrayner merged 1 commit into
mainfrom
perf/vertex-buffer
Oct 24, 2026
Merged

jackrayner merged 1 commit into
mainfrom
perf/vertex-buffer

Conversation

@jackrayner

Copy link
Copy Markdown
Owner

Port of upstream PR 187 (bolrog/d2dx, by Jarcho), tracker item 2. Upstream's reasoning: the oversized buffer can cause stalls longer than a frame when it is reallocated; the PR said it "hopefully" helps upstream issue 125 (regular stutter, Windows 7, 1.14d).

  • RenderContext's dynamic D3D11 vertex buffer goes from 4M to 1M vertices (64 MiB to 16 MiB at 16 bytes per vertex).
  • Overflow check: the CPU-side per-frame vertex array was already capped at 1M (D2DX_MAX_VERTICES_PER_FRAME), so the GPU buffer now equals the largest possible frame. BulkWriteVertices wraps with D3D11_MAP_WRITE_DISCARD when a write doesn't fit and clamps to capacity, so the smaller size adds no overflow path. (Separately, the CPU array is only guarded by Debug asserts, which is pre-existing and unchanged.)
  • The buffer will wrap about four times as often; whether that is smoother can only be seen in the game.

Cherry-picked with -x, Jarcho kept as author, change identical to the upstream PR. Please merge with a merge commit or rebase, not squash, to keep the authorship. Linux tests: 24 passed (they don't compile RenderContext); Windows CI is the build check.

🤖 Generated with Claude Code

The large buffer could result in stalls longer than the length of a frame when it gets reallocated.

(cherry picked from commit 51ceb1d)

Ported from upstream PR 187 (bolrog/d2dx).
@jackrayner
jackrayner merged commit 5d62ad0 into main Oct 24, 2026
4 checks passed
@jackrayner
jackrayner deleted the perf/vertex-buffer branch October 24, 2026 15:24
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