Skip to content

fix: stop frame timing and unit IDs losing precision in long sessions - #23

Merged
jackrayner merged 3 commits into
mainfrom
fix/fps-long-sessions
Oct 24, 2026
Merged

jackrayner merged 3 commits into
mainfrom
fix/fps-long-sessions

Conversation

@jackrayner

Copy link
Copy Markdown
Owner

Port of upstream PR 188 (bolrog/d2dx, by Jarcho), tracker item 1. It addresses the FPS slowdown after long play sessions reported in upstream issues 166, 146 and 141. That is the upstream author's claim; it hasn't been verified in the game here.

  • Frame time is computed from 64-bit QPC ticks (TimeEnd + TimeToMs) instead of a float that loses precision as the session gets longer (RenderContext, Utils).
  • The motion predictor keeps full 32-bit unit IDs and types instead of truncating them to 16 bits (UnitMotionPredictor), which could confuse units once IDs pass 65535.
  • tests/linux/shim/UtilsStub.cpp follows the new timing functions.
  • Extra commit from review: RenderContext::_prevTime is now initialised to 0, so the first frame's time isn't computed from garbage. That bug predates the port.

The upstream commits are cherry-picked with -x and keep Jarcho as author; the source changes are identical to the upstream PR. Please merge with a merge commit or rebase, not squash, so the authorship stays on the commits (squash would make the PR opener the author).

Checked: no other callers of the removed TimeEndMs; the widened UnitIdAndType is only accessed field by field (no SIMD or memory reinterpretation). Linux tests: 24 passed. Windows CI is the real build check.

🤖 Generated with Claude Code

Jarcho and others added 3 commits October 24, 2026 16:11
(cherry picked from commit 753c5ac)

Ported from upstream PR 188 (bolrog/d2dx).
Started after ~4 minutes due to float precision limits, would be visible after ~18-36 hours when it would be off by 4-8ms.

(cherry picked from commit d314ddd)

Ported from upstream PR 188 (bolrog/d2dx).
Shim update: tests/linux/shim/UtilsStub.cpp now stubs TimeEnd/TimeToMs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
RenderContext::_prevTime had no initial value, so the first Present()
computed the frame time against garbage. Text and weather motion
prediction read that frame time. The bug predates the port above (it was
an uninitialised double before); start from 0, which makes the first frame
time the time since the RenderContext was created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jackrayner
jackrayner merged commit 75c3cbe into main Oct 24, 2026
4 checks passed
@jackrayner
jackrayner deleted the fix/fps-long-sessions 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