Skip to content

Port upstream #174: a frame wait takes its tick before it sleeps - #50

Merged
DesertGamer merged 2 commits into
DesertGamer:mainfrom
lcg007xd-c:port/upstream-174-frame-wait-tick
Nov 26, 2026
Merged

DesertGamer merged 2 commits into
DesertGamer:mainfrom
lcg007xd-c:port/upstream-174-frame-wait-tick

Conversation

@lcg007xd-c

Copy link
Copy Markdown
Contributor

What this changes

This ports Marvisak/VIctory#174 by Manuel Pérez: both of its commits, cherry-picked with -x, so they keep their authorship. The second commit is the author's follow-up, which keeps the tick for the diagnostics log line.

frame::wait in crates/viport-gpu/src/frame.rs marks the tick it waited for as taken (LAST) only after the sleep, outside the clock's lock. Two threads waiting for the same event kind at once therefore both get the same tick and both return on it. That breaks the module's once-per-tick rule: an origin wait then begins two frames in one interval.

The fix makes next_tick take the tick under the clock's lock when the wait comes within its time-out. A time-out takes no tick, as before. The new test waits_begun_together_take_different_ticks checks this.

VIPort has the upstream merge of #174 in its history, but the change is not in the tree. It was lost in a later merge. Both commits applied without conflicts.

Checked

  • No game data of any kind (files, extracts, screenshots, dumps, saves): see docs/asset-policy.md
  • No binary files or archives
  • No new dependency, build.rs, git hook, .cargo config, CI change or script (or an issue explains why)
  • No download, no started program, no network connection added (or an issue explains why)
  • cargo test --workspace passes (not run, see below)
  • cargo clippy --workspace --all-targets --locked -- -D warnings passes (Windows target, run on Linux, with and without --all-features)
  • The code I wrote is formatted with rustfmt; I did not reformat lines I did not change

What I ran

viport-gpu builds only for Windows. On Linux, I compiled the clock part of frame.rs (everything above the tests, with tracing stubbed out) from main and from this branch, each with the new test:

  • main (the test calling the one-argument next_tick): fails with 1 after 1. Two waits begun together get the same tick.
  • This branch: passes.

cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, with and without --all-features: clean. The diagnostics build is what needs the second commit.

Not run: the Windows test run of viport-gpu, or the game. The CI test step will run the new test.

Overlaps

None. No open PR touches viport-gpu/src/frame.rs.

🤖 Generated with Claude Code

AndyLatimer and others added 2 commits November 25, 2026 19:34
frame::wait marked the tick it waited for as taken (LAST) only after
the sleep, outside the clock's lock, so two threads waiting for one
event kind at once both got the same tick and both returned on it,
against the module's once-per-tick rule (an origin wait then begins two
frames in one interval). next_tick now takes the tick under the clock's
lock when the wait comes within its time-out; a time-out takes none, as
before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 810f442)
The previous commit dropped the tick next_tick returns, but the
diagnostics build's tracing::debug! still names it (E0425). Bind it
again; it is unused without the feature, so that lint is allowed there.
Reported by Sunkiller-qc and r4tedx. cargo check -p victory-gpu passes
with and without --features diagnostics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 882664e)
@DesertGamer
DesertGamer merged commit 9280d6c into DesertGamer:main Nov 26, 2026
1 check failed
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.

3 participants