Pauses, hitches and flicker measured at every present: a smoothness: line, VICTORY_FLICKER_DETECT=1, and both in bench.ps1's summary #4377

Closed
github-bot wants to merge 13 commits from github-bot/gh-4376 into main AGit
Owner

@⁠IRennie74 on GitHub · 2026-11-30 19:26 UTC · original
IRennie74:pr/smoothness-flicker → main · +2489 −822 · 35 files · 13 commits · closed without merging

What it changes

The complaint was that the game flickers and pauses between frames, while scripts\bench.ps1 measured only frame-time averages and percentiles. A run with a good median and a good p99 can still stop for 300 ms twice a minute (the p99 of 10,000 frames hides 20 of them), and a frame that shows the wrong thing is on time. This adds two measurements and puts both in the bench summary. Nothing changes what is rendered or presented.

  • host/smooth.rs, the smoothness: line. Every present we issue is stamped, and a line about once a second gives presents, title frames, repeated and generated presents, the median and longest gap, hitches (a gap over 50 ms and over twice the running median of the last 120 gaps), pauses (any gap over 150 ms), frame-to-frame variability (the mean of |gap - previous gap|), and from DXGI's GetFrameStatistics the refreshes on which nothing new was ready, presents replaced before they were shown, and the longest time between two new images on the screen. It is on by default in diagnostics builds (VICTORY_SMOOTHNESS=0 turns it off) and only asked for in release builds (VICTORY_SMOOTHNESS=1). With the present handed to another queue or thread (VICTORY_PRESENT_QUEUE=1, VICTORY_PRESENT_ASIDE=1, both already on main) the stamp is the hand-off, and the module docs say so.
  • host/flicker.rs, VICTORY_FLICKER_DETECT=1 (diagnostics builds only). Each presented frame is shrunk on the card to 192x108 luminance pixels. This happens after the planes are composed and before our panel, notice, advisor and menu are drawn. The result goes into a ring of six read-backs that are read a few presents later, so nothing waits. A victory-flicker worker checks 16x9 tiles for A-B-A flicker, black flashes and frozen frames (byte-identical while the title's frame number advanced), then writes a flicker: line a second. The thresholds are VICTORY_FLICKER_{DELTA,REVERT,TILES,BLACK,BLACK_TILES,STILL}. The frames of the first 40 events, then of every 25th, are written as 576x108 PGMs to VICTORY_FLICKER_DIR, else to flicker beside VICTORY_LOG_FILE. These are the game's pixels, so a folder inside the source tree is refused (the same rule as victory_core::ensure_outside_repo, which victory-gpu does not depend on: adding it would change Cargo.lock and so every shader cache). Only with the switch does the swap chain ask for DXGI_USAGE_SHADER_INPUT. Without it, the swap chain is made exactly as before.
  • scripts\bench.ps1. There is a new -Flicker switch. summary.md/summary.json now give pauses, hitches, flicker, black flashes and frozen frames per minute, plus the longest gap, the variability, and the ten worst gaps and events (in seconds into the run, to line up with the log).
  • scripts\bench.ps1 reads victory.log with FileShare.ReadWrite | Delete. A title that had not exited within 30 s of being stopped still held its log open. ReadLines then threw and the run had no summary (2 of 18 walking runs on 2026-11-30). This is the same fix as part of open #3925. It is a commit of its own here, so it can be dropped if #3925 lands first.

How it was tested

  • GPU and profile: RTX 3060 12 GB, Ryzen 5 5600X, 32 GB; Series S profile, 960x540 internal, DLSS performance, frame generation off, ray tracing default.
  • What the lines found, walking with defaults (from the branch these commits come from, before the port to current main; docs/findings.md, "Pauses while walking", 2026-11-30):
    • 13-14 fps, with about 63 pauses a minute (present gaps over 150 ms, typically 190-260 ms) and 75-110 hitches.
    • Frame-to-frame variability was about 37 ms.
    • There were 51-84 A-B-A flicker events a minute. Some are ghosting of earlier frames, some striping on lights, and some only a fast camera between slow frames.
    • The once-a-second sweep() in Host::submit cost 56-67 ms while walking (up to 242 ms). A pause followed within 3 frames after 40-78 % of sweeps: 14-26 of the 63 a minute.
  • Before / After: this PR only measures, so there is no before/after for the game itself. The overhead of the smoothness: line was not measured in game. Its doc's estimate of some 5-20 us per present comes from the DXGI queries' documentation, not from a run. The flicker pass's cost (a compute pass of some 20,000 threads) was not measured in game either.
  • The port to current main was not run in game. It needed one conflict resolved in host.rs: main's VICTORY_PRESENT_QUEUE/VICTORY_PRESENT_ASIDE present branches, with the stamp taken before them. The resolved code was built with cargo build --locked --profile diag -p victory --features diagnostics.
  • scripts\bench.ps1 parses cleanly with PowerShell's parser. A bench run on this exact port was not done.
  • Shader wave sizes: not applicable (no shader changes).
  • cargo test passed for the crates it touches: yes for this PR's tests. cargo test -p victory-gpu --lib -- host::smooth host::flicker gives 25 passed, including the flicker pass shrinking a picture on WARP. The whole victory-gpu lib run gives 1153 passed and 5 failed, and all 5 failures are in files this PR does not touch: descriptor, host::card_steps, list::thin, pipeline::make, shader_cache.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without --features diagnostics: nothing in the files this PR touches. The remaining errors are pre-existing on main in other files: shadow.rs ranged unused, copystat.rs mb unused (diagnostics), and host.rs:5092 is_multiple_of in a test from an earlier commit.
  • cargo xtask policy --staged: ok.

Checked for overlap

  • I searched the open and merged pull requests for smoothness, flicker, hitch, bench.ps1, pacing and stutter. Related:
    • #3925 (open) has the same shared-read fix for victory.log in bench.ps1. It is kept as a separate commit here so either can go first.
    • #1128 (merged, host/pacing.rs) reports frame deadlines and DXGI Present outcomes. This PR adds gap-based pauses and hitches and GetFrameStatistics display counts, which that one does not have.
    • #3913 (open) samples DXGI present statistics on the FSR 3 proxy only, behind VICTORY_FSR_PRESENT_STATS=1. It is narrower and independent.
    • #3999 (open) adds frame-time threshold counts to the frame-times line. It is a different line with different measures.
    • No open or merged PR detects flicker, black flashes or frozen frames.
**@⁠IRennie74** on GitHub · 2026-11-30 19:26 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4376) `IRennie74:pr/smoothness-flicker` → `main` · +2489 −822 · 35 files · 13 commits · closed without merging ## What it changes The complaint was that the game flickers and pauses between frames, while `scripts\bench.ps1` measured only frame-time averages and percentiles. A run with a good median and a good p99 can still stop for 300 ms twice a minute (the p99 of 10,000 frames hides 20 of them), and a frame that shows the wrong thing is on time. This adds two measurements and puts both in the bench summary. Nothing changes what is rendered or presented. - **`host/smooth.rs`, the `smoothness:` line.** Every present we issue is stamped, and a line about once a second gives presents, title frames, repeated and generated presents, the median and longest gap, *hitches* (a gap over 50 ms and over twice the running median of the last 120 gaps), *pauses* (any gap over 150 ms), frame-to-frame variability (the mean of |gap - previous gap|), and from DXGI's `GetFrameStatistics` the refreshes on which nothing new was ready, presents replaced before they were shown, and the longest time between two new images on the screen. It is on by default in diagnostics builds (`VICTORY_SMOOTHNESS=0` turns it off) and only asked for in release builds (`VICTORY_SMOOTHNESS=1`). With the present handed to another queue or thread (`VICTORY_PRESENT_QUEUE=1`, `VICTORY_PRESENT_ASIDE=1`, both already on main) the stamp is the hand-off, and the module docs say so. - **`host/flicker.rs`, `VICTORY_FLICKER_DETECT=1` (diagnostics builds only).** Each presented frame is shrunk on the card to 192x108 luminance pixels. This happens after the planes are composed and before our panel, notice, advisor and menu are drawn. The result goes into a ring of six read-backs that are read a few presents later, so nothing waits. A `victory-flicker` worker checks 16x9 tiles for A-B-A flicker, black flashes and frozen frames (byte-identical while the title's frame number advanced), then writes a `flicker:` line a second. The thresholds are `VICTORY_FLICKER_{DELTA,REVERT,TILES,BLACK,BLACK_TILES,STILL}`. The frames of the first 40 events, then of every 25th, are written as 576x108 PGMs to `VICTORY_FLICKER_DIR`, else to `flicker` beside `VICTORY_LOG_FILE`. These are the game's pixels, so a folder inside the source tree is refused (the same rule as `victory_core::ensure_outside_repo`, which `victory-gpu` does not depend on: adding it would change `Cargo.lock` and so every shader cache). Only with the switch does the swap chain ask for `DXGI_USAGE_SHADER_INPUT`. Without it, the swap chain is made exactly as before. - **`scripts\bench.ps1`.** There is a new `-Flicker` switch. `summary.md`/`summary.json` now give pauses, hitches, flicker, black flashes and frozen frames per minute, plus the longest gap, the variability, and the ten worst gaps and events (in seconds into the run, to line up with the log). - **`scripts\bench.ps1` reads `victory.log` with `FileShare.ReadWrite | Delete`.** A title that had not exited within 30 s of being stopped still held its log open. `ReadLines` then threw and the run had no summary (2 of 18 walking runs on 2026-11-30). This is the same fix as part of open #3925. It is a commit of its own here, so it can be dropped if #3925 lands first. ## How it was tested - GPU and profile: RTX 3060 12 GB, Ryzen 5 5600X, 32 GB; Series S profile, 960x540 internal, DLSS performance, frame generation off, ray tracing default. - What the lines found, walking with defaults (from the branch these commits come from, before the port to current main; `docs/findings.md`, "Pauses while walking", 2026-11-30): - 13-14 fps, with about 63 pauses a minute (present gaps over 150 ms, typically 190-260 ms) and 75-110 hitches. - Frame-to-frame variability was about 37 ms. - There were 51-84 A-B-A flicker events a minute. Some are ghosting of earlier frames, some striping on lights, and some only a fast camera between slow frames. - The once-a-second `sweep()` in `Host::submit` cost 56-67 ms while walking (up to 242 ms). A pause followed within 3 frames after 40-78 % of sweeps: 14-26 of the 63 a minute. - Before / After: this PR only measures, so there is no before/after for the game itself. The overhead of the `smoothness:` line was not measured in game. Its doc's estimate of some 5-20 us per present comes from the DXGI queries' documentation, not from a run. The flicker pass's cost (a compute pass of some 20,000 threads) was not measured in game either. - The port to current main was not run in game. It needed one conflict resolved in `host.rs`: main's `VICTORY_PRESENT_QUEUE`/`VICTORY_PRESENT_ASIDE` present branches, with the stamp taken before them. The resolved code was built with `cargo build --locked --profile diag -p victory --features diagnostics`. - `scripts\bench.ps1` parses cleanly with PowerShell's parser. A bench run on this exact port was not done. - Shader wave sizes: not applicable (no shader changes). - `cargo test` passed for the crates it touches: yes for this PR's tests. `cargo test -p victory-gpu --lib -- host::smooth host::flicker` gives 25 passed, including the flicker pass shrinking a picture on WARP. The whole `victory-gpu` lib run gives 1153 passed and 5 failed, and all 5 failures are in files this PR does not touch: `descriptor`, `host::card_steps`, `list::thin`, `pipeline::make`, `shader_cache`. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`, with and without `--features diagnostics`: nothing in the files this PR touches. The remaining errors are pre-existing on main in other files: `shadow.rs` `ranged` unused, `copystat.rs` `mb` unused (diagnostics), and `host.rs:5092` `is_multiple_of` in a test from an earlier commit. - `cargo xtask policy --staged`: ok. ## Checked for overlap - [x] I searched the open and merged pull requests for `smoothness`, `flicker`, `hitch`, `bench.ps1`, `pacing` and `stutter`. Related: - #3925 (open) has the same shared-read fix for `victory.log` in `bench.ps1`. It is kept as a separate commit here so either can go first. - #1128 (merged, `host/pacing.rs`) reports frame deadlines and DXGI `Present` outcomes. This PR adds gap-based pauses and hitches and `GetFrameStatistics` display counts, which that one does not have. - #3913 (open) samples DXGI present statistics on the FSR 3 proxy only, behind `VICTORY_FSR_PRESENT_STATS=1`. It is narrower and independent. - #3999 (open) adds frame-time threshold counts to the frame-times line. It is a different line with different measures. - No open or merged PR detects flicker, black flashes or frozen frames.
A title that did not exit within 30 s of being stopped still held victory.log,
ReadLines threw, and the run had no summary (2 of 18 walking runs today).
The player sees the game flicker and pause between frames; the benchmark
measured only frame-time statistics.

- host/smooth.rs: every present stamped; a `smoothness:` line a second
  with presents, title frames, repeated and generated presents, median and
  longest gap, hitches (>50 ms and 2x the running median), pauses
  (>150 ms), frame-to-frame variability, and DXGI frame statistics (held
  refreshes, dropped presents, longest time between new images). On in
  diagnostics builds (VICTORY_SMOOTHNESS=0 off), asked for in release.
  With VICTORY_PRESENT_QUEUE=1 or VICTORY_PRESENT_ASIDE=1 the stamp is
  the hand-off to them.
- host/flicker.rs (VICTORY_FLICKER_DETECT=1, diagnostics): each presented
  frame, before our overlays, shrunk on the card to 192x108 luminance into
  a ring of read-backs read a few presents later; a worker judges 16x9
  tiles for A-B-A flicker, black flashes and frozen frames, writes a
  `flicker:` line a second and PGMs of the first events, never inside the
  source tree. Thresholds
  VICTORY_FLICKER_{DELTA,REVERT,TILES,BLACK,BLACK_TILES,STILL}. Its tests
  run in every build; its present-path half is allowed to go unused
  without diagnostics.
- scripts/bench.ps1: -Flicker; summary.md/json get pauses, hitches,
  flicker, black flashes and frozen frames per minute, the longest gap,
  the variability and the ten worst gaps and events (s into the run).

(Ported from c3e5f2d5 onto main, beside the present queue and present
thread branches.)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 19:28:47 +00:00
Author
Owner

@⁠M4gnif1cus on GitHub · 2026-11-30 22:16 UTC · original

Hi @⁠IRennie74, this fits well with the second F3 panel in #4542, which shows some of the same things on screen while playing:

  • Severe stutters: a frame over twice the typical one of the last 30 s and over 25 ms, counted for the session and drawn in red on a 30 s frame-time graph (the red is exactly what is counted).
  • Longest pause, plus P95, P99, max and pacing for the whole time the panel is open.
  • Menus, loading screens and the settling after a load are left out, so a load does not count as a pause.

Your smoothness: line measures at the present, which is more precise than the panel's own clock. If both land, the panel could take its hitch and pause figures from smooth.rs, so the overlay and bench.ps1 agree on one definition. Your thresholds (50 ms and twice the running median; 150 ms for a pause) are close to mine, and I am happy to adopt yours.

F3 second panel

**@⁠M4gnif1cus** on GitHub · 2026-11-30 22:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4376#issuecomment-7293610477) Hi @⁠IRennie74, this fits well with the second F3 panel in #4542, which shows some of the same things on screen while playing: - **Severe stutters**: a frame over twice the typical one of the last 30 s and over 25 ms, counted for the session and drawn in red on a 30 s frame-time graph (the red is exactly what is counted). - **Longest pause**, plus P95, P99, max and pacing for the whole time the panel is open. - Menus, loading screens and the settling after a load are left out, so a load does not count as a pause. Your `smoothness:` line measures at the present, which is more precise than the panel's own clock. If both land, the panel could take its hitch and pause figures from `smooth.rs`, so the overlay and `bench.ps1` agree on one definition. Your thresholds (50 ms and twice the running median; 150 ms for a pause) are close to mine, and I am happy to adopt yours. ![F3 second panel](https://raw.githubusercontent.com/M4gnif1cus/VIctory-NVIDIA/panel-f3-captura/panel-f3.png)
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:20 UTC · original

Thanks, that fits well. One definition for the overlay and bench.ps1 sounds right to me.

Two thoughts on how to join them:

  • Your load exclusion is the part smooth.rs lacks. Today a loading screen or the settling after a load counts as pauses in the smoothness: line, which inflates a run that crosses a load. If #4542 already knows when it is in a menu, loading or settling, smooth.rs could take that same signal and leave those gaps out, so both count the same frames.
  • A shared snapshot instead of two counters. I can add a small read-only smooth::snapshot() (session hitches, pauses, longest gap, the running median and the last N gaps) to this PR, so the panel reads it rather than keeping its own clock. Whichever lands second would then switch to it. Happy to adapt the thresholds too: yours are tuned for what a player sees, mine for what a 60 s bench window can count, and they are close enough to settle on one pair.

Let me know which order you would prefer, and I will follow it.

**@⁠IRennie74** on GitHub · 2026-11-30 22:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4376#issuecomment-7293707460) Thanks, that fits well. One definition for the overlay and `bench.ps1` sounds right to me. Two thoughts on how to join them: - **Your load exclusion is the part `smooth.rs` lacks.** Today a loading screen or the settling after a load counts as pauses in the `smoothness:` line, which inflates a run that crosses a load. If #4542 already knows when it is in a menu, loading or settling, `smooth.rs` could take that same signal and leave those gaps out, so both count the same frames. - **A shared snapshot instead of two counters.** I can add a small read-only `smooth::snapshot()` (session hitches, pauses, longest gap, the running median and the last N gaps) to this PR, so the panel reads it rather than keeping its own clock. Whichever lands second would then switch to it. Happy to adapt the thresholds too: yours are tuned for what a player sees, mine for what a 60 s bench window can count, and they are close enough to settle on one pair. Let me know which order you would prefer, and I will follow it.
Of 166 kept A-B-A frames of 2026-11-30 (Series S, DLSS performance, 15-20
fps), 154 were a camera turning between slow frames whose tiles' means came
back by chance. VICTORY_FLICKER_MATCH (8 levels): the most N+1 may differ
from N-1 within a flagged tile, pixel by pixel. Tiles that fail it are
counted on the line as moving=.
Author
Owner

@⁠IRennie74 on GitHub · 2026-12-01 00:01 UTC · original

Pushed one more commit: an A-B-A tile now has to come back pixel by pixel, not only in its mean (VICTORY_FLICKER_MATCH, 8 levels by default; tiles turned away this way are counted as moving= on the line).

Looking at the 166 A-B-A frames kept from today's walking runs (Series S, DLSS Performance, 15-20 fps), 154 were the camera turning between slow frames, where a tile's mean came back by chance while its pixels did not. With the new rule 12 of the 166 still count, and those are real one-frame events: a dark wedge over the cell window, lights appearing for one frame, a wrong frame of the opening logo. So the earlier "51-84 a minute" walking figure in the description overstates flicker by about an order of magnitude; the pause and hitch counts are unaffected.

@⁠M4gnif1cus, this matters for the shared definition too: anything reading flicker counts from this should take the matched count.

**@⁠IRennie74** on GitHub · 2026-12-01 00:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4376#issuecomment-7295833968) Pushed one more commit: an A-B-A tile now has to come back pixel by pixel, not only in its mean (`VICTORY_FLICKER_MATCH`, 8 levels by default; tiles turned away this way are counted as `moving=` on the line). Looking at the 166 A-B-A frames kept from today's walking runs (Series S, DLSS Performance, 15-20 fps), 154 were the camera turning between slow frames, where a tile's mean came back by chance while its pixels did not. With the new rule 12 of the 166 still count, and those are real one-frame events: a dark wedge over the cell window, lights appearing for one frame, a wrong frame of the opening logo. So the earlier "51-84 a minute" walking figure in the description overstates flicker by about an order of magnitude; the pause and hitch counts are unaffected. @⁠M4gnif1cus, this matters for the shared definition too: anything reading flicker counts from this should take the matched count.
Author
Owner

@⁠M4gnif1cus on GitHub · 2026-12-01 00:02 UTC · original

Thanks! I went with the load signal first: #4542 now has victory_gpu::in_play(), so the two pull requests stay independent and either can land first.

  • Some(true) in play, Some(false) paused, in a menu, on the map, in the settings overlay or before a player exists, None when the title's flags cannot be read (another build).
  • It comes from the title's own flags, the ones the input code already reads, set at each input poll. It works whether or not the F3 panel is shown, and with the native mouse hook off.
  • It does not cover the settling after a load: that depends on frame times, so I left it to whoever measures (the panel keeps its own wait).

smooth.rs could leave out the gaps where in_play() == Some(false), so a pause or a menu does not count as a hitch or a pause in the smoothness: line. A shared smooth::snapshot() for the panel's figures can follow once both are in, and the thresholds are open as I said.

**@⁠M4gnif1cus** on GitHub · 2026-12-01 00:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4376#issuecomment-7295840788) Thanks! I went with the load signal first: #4542 now has `victory_gpu::in_play()`, so the two pull requests stay independent and either can land first. - `Some(true)` in play, `Some(false)` paused, in a menu, on the map, in the settings overlay or before a player exists, `None` when the title's flags cannot be read (another build). - It comes from the title's own flags, the ones the input code already reads, set at each input poll. It works whether or not the F3 panel is shown, and with the native mouse hook off. - It does not cover the settling after a load: that depends on frame times, so I left it to whoever measures (the panel keeps its own wait). `smooth.rs` could leave out the gaps where `in_play() == Some(false)`, so a pause or a menu does not count as a hitch or a pause in the `smoothness:` line. A shared `smooth::snapshot()` for the panel's figures can follow once both are in, and the thresholds are open as I said.
Author
Owner

@⁠IRennie74 on GitHub · 2026-12-01 00:30 UTC · original

That works well, thanks. Keeping the two independent is the right call.

Once #4542 is in, I'll make smooth.rs leave out gaps that begin or end while in_play() == Some(false), and count them separately on the line (as out of play) so a run still shows how much it spent in menus or paused. None will keep today's behaviour, so other builds are unaffected. The settling after a load I'll leave to the frame-time side too, as you suggest; for the bench it mostly falls in the warm-up window anyway.

Then the snapshot can follow as you say.

**@⁠IRennie74** on GitHub · 2026-12-01 00:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4376#issuecomment-7296422915) That works well, thanks. Keeping the two independent is the right call. Once #4542 is in, I'll make `smooth.rs` leave out gaps that begin or end while `in_play() == Some(false)`, and count them separately on the line (as `out of play`) so a run still shows how much it spent in menus or paused. `None` will keep today's behaviour, so other builds are unaffected. The settling after a load I'll leave to the frame-time side too, as you suggest; for the bench it mostly falls in the warm-up window anyway. Then the snapshot can follow as you say.
github-bot closed this pull request 2026-12-01 18:43:46 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:42 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4376#issuecomment-7321376784) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4377
No description provided.