GPU & CLI: configurable/uncapped FPS limit, high-res pacing, high-refresh modes, and tearing swapchain #250

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

@⁠wbkepler on GitHub · 2026-11-24 01:49 UTC · original
wbkepler:gpu/configurable-fps-limit → main · +757 −67 · 10 files · 1 commits · open

Summary

Makes console frame pacing configurable (including uncapped) and upgrades host presentation for high-refresh displays:

  • Config & CLI (victory-core, victory.example.toml, apps/victory):
    • Adds optional [graphics] section (fps_limit, allow_tearing) with #[serde(default)] to FileConfig (victory.example.toml updated).
    • Adds --fps <N> CLI flag on victory run (0 = uncapped) and VICTORY_FPS_LIMIT / VICTORY_ALLOW_TEARING env overrides (precedence: --fps > env > victory.toml > title default).
  • Frame pacing (victory-gpu/src/frame.rs):
    • Exposes frame::set_fps_limit(Option<u32>) overriding SetFrameIntervalX (Some(0) returns immediately while advancing tokens/ticks; Some(n) sets round(1_000_000 / n) us logged once at info!).
    • Replaces coarse thread::sleep with a thread-local Windows high-resolution waitable timer (CREATE_WAITABLE_TIMER_HIGH_RESOLUTION) plus 500 us spin tail (with thread::sleep fallback).
    • Tracks monotonic FrameStats via frame::stats() while keeping the COM statistics entry point safe.
  • High-refresh DXGI modes & tearing swapchain (dxgi.rs, host.rs):
    • Advertises 4K progressive modes at 60/120/144/240 Hz (plus host display refresh if distinct) in dxgi.rs with DXGI MORE_DATA semantics.
    • Upgrades host.rs flip-model swapchain to 3 buffers and probes IDXGIFactory5::CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING), passing ALLOW_TEARING on creation, ResizeBuffers, and Present(0, flags) with automatic fallback to Present(0, 0).
  • Adds unit tests across victory-core (10/10) and victory-gpu (45/45).

Verification

  • cargo clippy --workspace --all-targets — passed (zero new warnings)
  • cargo clippy -p victory --features diagnostics --all-targets — passed
  • cargo test --workspace — passed
  • cargo xtask policy — passed (151 files ok)
**@⁠wbkepler** on GitHub · 2026-11-24 01:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/250) `wbkepler:gpu/configurable-fps-limit` → `main` · +757 −67 · 10 files · 1 commits · open ## Summary Makes console frame pacing configurable (including uncapped) and upgrades host presentation for high-refresh displays: - **Config & CLI (`victory-core`, `victory.example.toml`, `apps/victory`)**: - Adds optional `[graphics]` section (`fps_limit`, `allow_tearing`) with `#[serde(default)]` to `FileConfig` (`victory.example.toml` updated). - Adds `--fps <N>` CLI flag on `victory run` (`0` = uncapped) and `VICTORY_FPS_LIMIT` / `VICTORY_ALLOW_TEARING` env overrides (precedence: `--fps` > env > `victory.toml` > title default). - **Frame pacing (`victory-gpu/src/frame.rs`)**: - Exposes `frame::set_fps_limit(Option<u32>)` overriding `SetFrameIntervalX` (`Some(0)` returns immediately while advancing tokens/ticks; `Some(n)` sets `round(1_000_000 / n)` us logged once at `info!`). - Replaces coarse `thread::sleep` with a thread-local Windows high-resolution waitable timer (`CREATE_WAITABLE_TIMER_HIGH_RESOLUTION`) plus 500 us spin tail (with `thread::sleep` fallback). - Tracks monotonic `FrameStats` via `frame::stats()` while keeping the COM statistics entry point safe. - **High-refresh DXGI modes & tearing swapchain (`dxgi.rs`, `host.rs`)**: - Advertises 4K progressive modes at 60/120/144/240 Hz (plus host display refresh if distinct) in `dxgi.rs` with DXGI `MORE_DATA` semantics. - Upgrades `host.rs` flip-model swapchain to 3 buffers and probes `IDXGIFactory5::CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING)`, passing `ALLOW_TEARING` on creation, `ResizeBuffers`, and `Present(0, flags)` with automatic fallback to `Present(0, 0)`. - Adds unit tests across `victory-core` (10/10) and `victory-gpu` (45/45). ## Verification - `cargo clippy --workspace --all-targets` — passed (zero new warnings) - `cargo clippy -p victory --features diagnostics --all-targets` — passed - `cargo test --workspace` — passed - `cargo xtask policy` — passed (151 files ok)
Adds [graphics] fps_limit/allow_tearing, --fps, VICTORY_FPS_LIMIT, an override of
the title's SetFrameIntervalX interval, a high-resolution waitable timer, 60-240 Hz
display modes and a 3-buffer ALLOW_TEARING swapchain.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:38 +00:00
Author
Owner

@⁠GamingRipperDoc on GitHub · 2026-11-24 04:46 UTC · original

First test report, on Windows 10 + AMD: the uncapped limit works, but only until the title starts loading the story; from there on frames are paced at exactly 30 fps again.

Setup: Windows 10 22H2 19045.7846, RX 9070 XT (driver 32.0.32015.7029), Ryzen 9 9900X, 3840x2160 window. main d2a4bae + #175 (Agility SDK, needed on Windows 10) + #336 + this PR at 8a84e85. One conflict with #175 in apps/victory/src/main.rs: both add lines to show_config at the same spot; I kept both (d3d12 sdk then fps_limit/tearing). Diag build, VICTORY_FPS_LIMIT=0.

  • victory config shows fps_limit : uncapped with the env var and (title default) without it; tearing : true.
  • At startup: frame interval overridden: uncapped (fps_limit = 0) title_interval=33.333ms and presenting to a window width=3840 height=2160 format=28 buffers=3 tearing=true.

From the runtime's per-5 s fps, ms/frame lines:

phase before (same base without this PR) with this PR, uncapped
first ~15 s 30.0 fps 685–778 fps (1.3–1.5 ms)
next ~15 s 30.0 fps 274–308 fps (3.2–3.7 ms)
from the moment the title opens its story packs (frame ~13,866 here) through the intro, menus and loading 30.0 fps 30.0 fps, 33.3 ms, with ~1–2 ms of preparation and ~1 ms on the GPU
world ~1 fps ~0.2–1.6 fps (no change expected)

The uncapped part looked right to me: no visible speed-up of animation or audio, and no tearing I noticed. But after the switch the frames sit at exactly 33.3 ms while the work takes ~3 ms, so something keeps pacing them at 30 that set_fps_limit doesn't override: the title calling SetFrameIntervalX again, a wait kind this PR doesn't cover, or the title's own timing. I didn't run with VICTORY_LOG=victory_gpu::frame=debug, which would show the frame wait kind=… timeout_ms=… lines; happy to, if that helps.

No game data used.

AI-assisted (Claude Code); I played the run.

**@⁠GamingRipperDoc** on GitHub · 2026-11-24 04:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/250#issuecomment-7122326757) First test report, on Windows 10 + AMD: the uncapped limit works, but only until the title starts loading the story; from there on frames are paced at exactly 30 fps again. **Setup:** Windows 10 22H2 19045.7846, RX 9070 XT (driver 32.0.32015.7029), Ryzen 9 9900X, 3840x2160 window. `main` `d2a4bae` + #175 (Agility SDK, needed on Windows 10) + #336 + this PR at `8a84e85`. One conflict with #175 in `apps/victory/src/main.rs`: both add lines to `show_config` at the same spot; I kept both (`d3d12 sdk` then `fps_limit`/`tearing`). Diag build, `VICTORY_FPS_LIMIT=0`. - `victory config` shows `fps_limit : uncapped` with the env var and `(title default)` without it; `tearing : true`. - At startup: `frame interval overridden: uncapped (fps_limit = 0) title_interval=33.333ms` and `presenting to a window width=3840 height=2160 format=28 buffers=3 tearing=true`. From the runtime's per-5 s `fps, ms/frame` lines: | phase | before (same base without this PR) | with this PR, uncapped | |---|---|---| | first ~15 s | 30.0 fps | **685–778 fps** (1.3–1.5 ms) | | next ~15 s | 30.0 fps | **274–308 fps** (3.2–3.7 ms) | | from the moment the title opens its story packs (frame ~13,866 here) through the intro, menus and loading | 30.0 fps | **30.0 fps**, 33.3 ms, with ~1–2 ms of preparation and ~1 ms on the GPU | | world | ~1 fps | ~0.2–1.6 fps (no change expected) | The uncapped part looked right to me: no visible speed-up of animation or audio, and no tearing I noticed. But after the switch the frames sit at exactly 33.3 ms while the work takes ~3 ms, so something keeps pacing them at 30 that `set_fps_limit` doesn't override: the title calling `SetFrameIntervalX` again, a wait kind this PR doesn't cover, or the title's own timing. I didn't run with `VICTORY_LOG=victory_gpu::frame=debug`, which would show the `frame wait kind=… timeout_ms=…` lines; happy to, if that helps. No game data used. AI-assisted (Claude Code); I played the run.
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 05:44 UTC · original

Tested current PR head 8a84e85c9d88f45205e40e235aaa5093e9edf085.

  • cargo test --locked -p victory-core --lib config -- --test-threads=1: 6 passed. This covers optional graphics defaults, file parsing, environment-over-file precedence for FPS/tearing, and invalid environment values.
  • cargo test --locked -p victory-gpu --lib frame -- --test-threads=1: 2 passed. The cases cover title-default, uncapped, and 60/120/144/240-FPS interval math; timeout/origin/flip token sequencing; an immediate uncapped loop; and frame statistics (clock tests).
  • cargo test --locked -p victory-gpu --lib output_enumerates_high_refresh_modes -- --test-threads=1: 1 passed. It checks 4K 60/120/144/240-Hz modes, a custom host rate, duplicate removal, and the undersized-buffer MORE_DATA case (mode test).
  • cargo test --locked -p victory -- --test-threads=1: 1 passed and the CLI package built. cargo run --locked -p victory -- run --help also displays the new --fps option and its documented precedence; no title was run.

These tests do not exercise a real swapchain, adapter/display tearing support, or the reported return to 30 FPS during story loading. The CLI package test is an existing loader-lock test, so it does not verify the --fps override in a running title.

**@⁠jeremygold02** on GitHub · 2026-11-24 05:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/250#issuecomment-7123222308) Tested current PR head `8a84e85c9d88f45205e40e235aaa5093e9edf085`. - `cargo test --locked -p victory-core --lib config -- --test-threads=1`: 6 passed. This covers optional graphics defaults, file parsing, environment-over-file precedence for FPS/tearing, and invalid environment values. - `cargo test --locked -p victory-gpu --lib frame -- --test-threads=1`: 2 passed. The cases cover title-default, uncapped, and 60/120/144/240-FPS interval math; timeout/origin/flip token sequencing; an immediate uncapped loop; and frame statistics ([clock tests](https://github.com/Marvisak/VIctory/blob/8a84e85c9d88f45205e40e235aaa5093e9edf085/crates/victory-gpu/src/frame.rs#L392-L500)). - `cargo test --locked -p victory-gpu --lib output_enumerates_high_refresh_modes -- --test-threads=1`: 1 passed. It checks 4K 60/120/144/240-Hz modes, a custom host rate, duplicate removal, and the undersized-buffer `MORE_DATA` case ([mode test](https://github.com/Marvisak/VIctory/blob/8a84e85c9d88f45205e40e235aaa5093e9edf085/crates/victory-gpu/src/dxgi.rs#L362-L431)). - `cargo test --locked -p victory -- --test-threads=1`: 1 passed and the CLI package built. `cargo run --locked -p victory -- run --help` also displays the new `--fps` option and its documented precedence; no title was run. These tests do not exercise a real swapchain, adapter/display tearing support, or the reported return to 30 FPS during story loading. The CLI package test is an existing loader-lock test, so it does not verify the `--fps` override in a running title.
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 06:50 UTC · original

Thanks @⁠GamingRipperDoc for the detailed report!

I audited every frame-pacing, wait, and present path across victory-gpu (frame.rs, queue.rs, host.rs, dxgi.rs, device.rs) and victory-hle:

  • SetFrameIntervalX re-calls: FPS_LIMIT is set once at startup (Some(0) for uncapped) and never reset. Any subsequent SetFrameIntervalX call re-runs effective_interval(title_interval, Some(0)) -> None, so the uncapped override stays active.
  • All WaitFrameEventX event kinds: when interval is None, next_tick(kind) returns Duration::ZERO for every event kind (ORIGIN, VBLANK, FLIP, etc.), so frame::wait returns S_OK with zero sleep.
  • PresentX / DXGI: Host::present passes SyncInterval = 0 with DXGI_PRESENT_ALLOW_TEARING (and SyncInterval = 0 on fallback), and IDXGIOutput has no WaitForVBlank sleep path.

That strongly points to the lock-back to 30.0 fps (33.3 ms) around frame ~13,866 being the title's own CPU-side frame/simulation limiter (e.g. a QPC + Sleep/timer loop targeting 33.3 ms once it leaves early boot and enters the intro/menu/loading loop), rather than a second pacing path inside victory-gpu.

Pushed a small follow-up commit to frame.rs so repeated SetFrameIntervalX calls also log at debug (instead of being silenced by Once), plus a test covering repeated set_interval calls across all event kinds in uncapped mode. If you do another quick run with VICTORY_LOG=victory_gpu::frame=debug, checking whether frame wait still logs wait_us=0 during the 30.0 fps phase (and whether any frame interval re-set lines appear) will confirm conclusively whether victory-gpu is sleeping at all there.

**@⁠wbkepler** on GitHub · 2026-11-24 06:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/250#issuecomment-7124341183) Thanks @⁠GamingRipperDoc for the detailed report! I audited every frame-pacing, wait, and present path across `victory-gpu` (`frame.rs`, `queue.rs`, `host.rs`, `dxgi.rs`, `device.rs`) and `victory-hle`: - **`SetFrameIntervalX` re-calls**: `FPS_LIMIT` is set once at startup (`Some(0)` for uncapped) and never reset. Any subsequent `SetFrameIntervalX` call re-runs `effective_interval(title_interval, Some(0))` -> `None`, so the uncapped override stays active. - **All `WaitFrameEventX` event kinds**: when `interval` is `None`, `next_tick(kind)` returns `Duration::ZERO` for every event kind (`ORIGIN`, `VBLANK`, `FLIP`, etc.), so `frame::wait` returns `S_OK` with zero sleep. - **`PresentX` / DXGI**: `Host::present` passes `SyncInterval = 0` with `DXGI_PRESENT_ALLOW_TEARING` (and `SyncInterval = 0` on fallback), and `IDXGIOutput` has no `WaitForVBlank` sleep path. That strongly points to the lock-back to 30.0 fps (33.3 ms) around frame ~13,866 being the title's own CPU-side frame/simulation limiter (e.g. a QPC + `Sleep`/timer loop targeting 33.3 ms once it leaves early boot and enters the intro/menu/loading loop), rather than a second pacing path inside `victory-gpu`. Pushed a small follow-up commit to `frame.rs` so repeated `SetFrameIntervalX` calls also log at `debug` (instead of being silenced by `Once`), plus a test covering repeated `set_interval` calls across all event kinds in uncapped mode. If you do another quick run with `VICTORY_LOG=victory_gpu::frame=debug`, checking whether `frame wait` still logs `wait_us=0` during the 30.0 fps phase (and whether any `frame interval re-set` lines appear) will confirm conclusively whether `victory-gpu` is sleeping at all there.
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 20:40 UTC · original

Rebased onto current main (ffe310e) as 6fa50e2; conflicts were in config.rs (upstream's flat test_titles file config vs this PR's [paths]/[graphics] split; its tests now use FileConfig) and the show_config output (kept both data_dir and the fps lines). Gate (clippy -D warnings, tests, policy) clean.

AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.

**@⁠wbkepler** on GitHub · 2026-11-24 20:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/250#issuecomment-7143904593) Rebased onto current main (`ffe310e`) as `6fa50e2`; conflicts were in config.rs (upstream's flat `test_titles` file config vs this PR's `[paths]`/`[graphics]` split; its tests now use `FileConfig`) and the `show_config` output (kept both `data_dir` and the fps lines). Gate (clippy -D warnings, tests, policy) clean. _AI-assisted (Claude Code); checked on Windows 11 / RTX 5090._
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 22:18 UTC · original

Rebased onto 70564ae as 6c2c141 (squashed to one commit). Adapted: kept upstream's fidelityfx_dir config key and show_config line alongside the new [graphics] section/fps_limit output, and kept upstream's 50 ms tick in the frame pacing test (the PR's module-level FLIP constant replaces the test-local one). Gate: clippy -D warnings (core, gpu, victory, victory+diagnostics), tests and cargo xtask policy pass; two pre-existing view-heap-cap tests fail identically on plain upstream on this host.

AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.

**@⁠wbkepler** on GitHub · 2026-11-24 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/250#issuecomment-7146058390) Rebased onto `70564ae` as `6c2c141` (squashed to one commit). Adapted: kept upstream's `fidelityfx_dir` config key and `show_config` line alongside the new `[graphics]` section/`fps_limit` output, and kept upstream's 50 ms tick in the frame pacing test (the PR's module-level `FLIP` constant replaces the test-local one). Gate: clippy -D warnings (core, gpu, victory, victory+diagnostics), tests and `cargo xtask policy` pass; two pre-existing view-heap-cap tests fail identically on plain upstream on this host. _AI-assisted (Claude Code); checked on Windows 11 / RTX 5090._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:27 UTC · original · edited 2026-11-25 15:56 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/frame.rs, crates/victory-gpu/src/lib.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/250#issuecomment-7148527698) · edited 2026-11-25 15:56 UTC <!-- victory-triage v1 head=1899bb5261afac8a6afc968c33b8d886a5ee093b verdict=needs-rebase at=2026-11-25T15:55:50Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/frame.rs`, `crates/victory-gpu/src/lib.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠wbkepler on GitHub · 2026-11-25 07:13 UTC · original

Rebased onto current main (940d32f) as 1899bb5; conflicts were with the frame-wait tick now taken before the sleep (kept upstream's, the uncapped path takes its tick too), the swap-chain retry/error steps (tearing flags folded into them) and run now returning the exit status (fps added).

AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.

**@⁠wbkepler** on GitHub · 2026-11-25 07:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/250#issuecomment-7155632732) Rebased onto current main (`940d32f`) as `1899bb5`; conflicts were with the frame-wait tick now taken before the sleep (kept upstream's, the uncapped path takes its tick too), the swap-chain retry/error steps (tearing flags folded into them) and `run` now returning the exit status (`fps` added). _AI-assisted (Claude Code); checked on Windows 11 / RTX 5090._
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/frame.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/lib.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-250'
git switch 'github-bot/gh-250'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-250'
git switch 'github-bot/gh-250'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-250'
git switch 'main'
git merge --squash 'github-bot/gh-250'
git switch 'main'
git merge --ff-only 'github-bot/gh-250'
git switch 'main'
git merge 'github-bot/gh-250'
git push origin 'main'
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/Marvisak--VIctory!250
No description provided.