GPU: hold a present with no flip wait since the last one to its flip tick (intro movie judder) #457

Open
github-bot wants to merge 1 commit from github-bot/gh-457 into main AGit
Owner

@⁠GamingRipperDoc on GitHub · 2026-11-25 01:05 UTC · original
GamingRipperDoc:flip-pacing → main · +46 −1 · 2 files · 1 commits · open

The intro movie judders through its first seconds. Root cause: the title's catch-up presents are shown at once instead of on their flip tick.

What happens

The title polls the frame origin with "token on time-out" and normally waits for the flip before each present (frame.rs's own notes). While the movie player is behind, right after playback starts, it begins a frame early and presents it without the flip wait. The console flips such a frame on the next flip tick, so the cadence stays even. VIctory hands every present to the host at once (Present(0, …)), so that frame stayed on screen ~5 ms and the frames around it twice as long.

Measured on the intro movie with per-present logging and a local check of the movie's texture buffers (the 8 MB luma + 2 × 2 MB chroma, three sets in rotation), over the same ~15 s:

before with this PR
presents 478 453
presents with a new movie frame 450 450
presents repeating the previous movie frame 28 (27 in the first 6 s) 3
presents < 20 ms after the previous one 25 0
median / max interval 33.26 / 37.9 ms 33.33 / 66.9 ms (once)

Every extra present came right after an origin poll that timed out (frame wait kind=0 timeout_ms=0 flags=2 hr=1) with no kind=2 wait before it; the next present then had no new movie frame. Background shader translation was ruled out (none during those seconds), and the texture checks are exact (hash at submission).

Change

frame::before_present(), called right before the host Present: if no flip wait has ended since the last present, it sleeps to the next flip tick and takes it (last(FLIP)), so each present still gets one tick and the next frame's flip wait lands after it. Presents after a flip wait, which is every frame in normal play, including slow world frames with this tree's early-ending waits, are not delayed. Two files, +47/−1.

A test extends waits_end_on_ticks_and_count_frames (the clock is global, so it stays in that test): a present after a flip wait takes no tick; a second present with no flip wait takes the next tick; the following flip wait lands after it. It failed before the change.

Tested

Windows 10 22H2, AMD RX 9070 XT, Ryzen 9 9900X:

  • cargo test -p victory-gpu: 112 passed. cargo clippy --workspace --all-targets --locked [--all-features] -- -D warnings: clean. rustfmt --check on frame.rs: clean.
  • In game: the table above. Because this tree's build currently stops in the first-boot screens on AMD (#422), the in-game numbers come from the same commit applied to an upstream-based build (ffe310e + #420's Agility runtime + Marvisak/VIctory#431, Marvisak/VIctory#568 and Marvisak/VIctory#67), where frame.rs matches this tree's except for the early-ending waits; the patch applied there unchanged.

No game data used.

AI-assisted (Claude Code); I watched both runs and the logs were read with the model.

**@⁠GamingRipperDoc** on GitHub · 2026-11-25 01:05 UTC · [original](https://github.com/fxceless/victory-fork/pull/457) `GamingRipperDoc:flip-pacing` → `main` · +46 −1 · 2 files · 1 commits · open The intro movie judders through its first seconds. Root cause: the title's catch-up presents are shown at once instead of on their flip tick. ## What happens The title polls the frame origin with "token on time-out" and normally waits for the flip before each present (`frame.rs`'s own notes). While the movie player is behind, right after playback starts, it begins a frame early and presents it **without** the flip wait. The console flips such a frame on the next flip tick, so the cadence stays even. VIctory hands every present to the host at once (`Present(0, …)`), so that frame stayed on screen ~5 ms and the frames around it twice as long. Measured on the intro movie with per-present logging and a local check of the movie's texture buffers (the 8 MB luma + 2 × 2 MB chroma, three sets in rotation), over the same ~15 s: | | before | with this PR | |---|---|---| | presents | 478 | 453 | | presents with a new movie frame | 450 | 450 | | presents repeating the previous movie frame | **28** (27 in the first 6 s) | **3** | | presents < 20 ms after the previous one | **25** | **0** | | median / max interval | 33.26 / 37.9 ms | 33.33 / 66.9 ms (once) | Every extra present came right after an origin poll that timed out (`frame wait kind=0 timeout_ms=0 flags=2 hr=1`) with no `kind=2` wait before it; the next present then had no new movie frame. Background shader translation was ruled out (none during those seconds), and the texture checks are exact (hash at submission). ## Change `frame::before_present()`, called right before the host `Present`: if no flip wait has ended since the last present, it sleeps to the next flip tick and takes it (`last(FLIP)`), so each present still gets one tick and the next frame's flip wait lands after it. Presents after a flip wait, which is every frame in normal play, including slow world frames with this tree's early-ending waits, are not delayed. Two files, +47/−1. A test extends `waits_end_on_ticks_and_count_frames` (the clock is global, so it stays in that test): a present after a flip wait takes no tick; a second present with no flip wait takes the next tick; the following flip wait lands after it. It failed before the change. ## Tested Windows 10 22H2, AMD RX 9070 XT, Ryzen 9 9900X: - `cargo test -p victory-gpu`: 112 passed. `cargo clippy --workspace --all-targets --locked [--all-features] -- -D warnings`: clean. `rustfmt --check` on `frame.rs`: clean. - In game: the table above. Because this tree's build currently stops in the first-boot screens on AMD (#422), the in-game numbers come from the same commit applied to an upstream-based build (`ffe310e` + #420's Agility runtime + Marvisak/VIctory#431, Marvisak/VIctory#568 and Marvisak/VIctory#67), where `frame.rs` matches this tree's except for the early-ending waits; the patch applied there unchanged. No game data used. AI-assisted (Claude Code); I watched both runs and the logs were read with the model.
The title polls the frame origin with "token on time-out" and normally
waits for the flip before each present. When its movie player falls
behind, it presents a frame begun early without that flip wait. The console
flips such a frame on the next flip tick; we presented it at once, so it
stayed on screen ~5 ms and its neighbours twice as long: the intro movie
juddered through its first seconds (27 such presents in 5 s, each followed
by a present with no new movie frame).

before_present() now holds such a present until the next flip tick and
takes that tick, so each present still gets one tick. Presents after a
flip wait (every frame in normal play, and slow world frames) are not
delayed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:43:46 +00:00
github-bot force-pushed github-bot/gh-457 from af08b20baf to 2fd1402328 2026-11-26 06:45:53 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/457/head:github-bot/gh-457'
git switch 'github-bot/gh-457'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-457'
git switch 'github-bot/gh-457'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-457'
git switch 'github-bot/gh-457'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-457'
git switch 'main'
git merge --squash 'github-bot/gh-457'
git switch 'main'
git merge --ff-only 'github-bot/gh-457'
git switch 'main'
git merge 'github-bot/gh-457'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.