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

Open
GamingRipperDoc wants to merge 1 commit from upstream-pr/457 into main
GamingRipperDoc commented 2026-11-25 01:05:56 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by GamingRipperDoc on 2026-11-25T01:05:56Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5483113097 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/457). Originally posted by [GamingRipperDoc](https://github.com/GamingRipperDoc) on 2026-11-25T01:05:56Z. --- 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/457:upstream-pr/457'
git switch 'upstream-pr/457'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/457'
git switch 'upstream-pr/457'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/457'
git switch 'upstream-pr/457'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/457'
git switch 'main'
git merge --squash 'upstream-pr/457'
git switch 'main'
git merge --ff-only 'upstream-pr/457'
git switch 'main'
git merge 'upstream-pr/457'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!457
No description provided.