perf(gpu): default swap chain to triple buffering (VICTORY_SWAP_BUFFERS) #1193

Closed
github-bot wants to merge 1 commit from github-bot/gh-1193 into main AGit
Owner

@⁠champagneluv on GitHub · 2026-11-28 15:17 UTC · original
perf/triple-buffering → main · +39 −5 · 3 files · 1 commits · closed without merging

Summary

  • Replace hardcoded \const BUFFERS: u32 = 2\ in \crates/victory-gpu/src/host.rs\ with \swap_buffers()\ (configurable via \VICTORY_SWAP_BUFFERS, clamped to \2..=4, defaulting to \3).
  • Sync \options.num_back_buffers\ in \crates/victory-gpu/src/streamline.rs\ with \crate::host::swap_buffers().
  • Expose \VICTORY_SWAP_BUFFERS\ (\3 (TRIPLE)\ / \2 (DOUBLE)) in the F1 settings menu (\crates/victory-gpu/src/host/menu.rs).
  • Add unit tests (\swap_buffers_tests::defaults_to_triple_and_clamps_range) verifying default, clamping, and invalid/empty input handling.

Why

With \late_free_present()\ (\VICTORY_RELAY=2, default in \play.rs) and tearing enabled, presents are queued ahead of completion. Using 3 back buffers instead of 2 avoids CPU/GPU stalls waiting for a back buffer to retire when multiple frames are in flight.

Verification

  • \cargo clippy --all-targets --all-features\ — 0 warnings on changed files
  • \cargo test -p victory-gpu\ — 455 passed, 0 failed (36 ignored)
  • \cargo build --release -p victory\ — succeeded
**@⁠champagneluv** on GitHub · 2026-11-28 15:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1193) `perf/triple-buffering` → `main` · +39 −5 · 3 files · 1 commits · closed without merging ### Summary - Replace hardcoded \const BUFFERS: u32 = 2\ in \crates/victory-gpu/src/host.rs\ with \swap_buffers()\ (configurable via \VICTORY_SWAP_BUFFERS\, clamped to \2..=4\, defaulting to \3\). - Sync \options.num_back_buffers\ in \crates/victory-gpu/src/streamline.rs\ with \crate::host::swap_buffers()\. - Expose \VICTORY_SWAP_BUFFERS\ (\3 (TRIPLE)\ / \2 (DOUBLE)\) in the F1 settings menu (\crates/victory-gpu/src/host/menu.rs\). - Add unit tests (\swap_buffers_tests::defaults_to_triple_and_clamps_range\) verifying default, clamping, and invalid/empty input handling. ### Why With \late_free_present()\ (\VICTORY_RELAY=2\, default in \play.rs\) and tearing enabled, presents are queued ahead of completion. Using 3 back buffers instead of 2 avoids CPU/GPU stalls waiting for a back buffer to retire when multiple frames are in flight. ### Verification - \cargo clippy --all-targets --all-features\ — 0 warnings on changed files - \cargo test -p victory-gpu\ — 455 passed, 0 failed (36 ignored) - \cargo build --release -p victory\ — succeeded
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 15:22:20 +00:00
Author
Owner

@⁠Bj0rnis on GitHub · 2026-11-28 16:58 UTC · original

Verified 686a0fd0 on RTX 5070 Ti 16 GB (Blackwell, driver 621.24, Streamline 2.14.16 / NGX 310.9.16) + Ryzen 7 9800X3D, 32 GB RAM, Windows 11 (Rust 1.98.1).

Automated checks

  • git merge-tree vs origin/main (9ce3cf9): clean.
  • cargo test --locked -p victory-gpu --features diagnostics --lib (RTX 5070 Ti): 508 passed, 0 failed, 36 ignored (including host::swap_buffers_tests::defaults_to_triple_and_clamps_range).
  • cargo clippy --locked -p victory-gpu --tests: 0 new warnings (only pre-existing shadow.rs:1708 manual_is_multiple_of).
  • victory.exe upscaler-check --device --present (2560×1440 DLSS Quality + 2× FG):
    • Default (buffers=3): 180/180 FG presents, 360 frames shown, status 0x0, clean shutdown (swap-chain VRAM delta 299 → 622 MB, +15 MB vs double buffering).
    • VICTORY_SWAP_BUFFERS=2: 180/180 FG presents, 360 frames shown, status 0x0, clean shutdown (swap-chain VRAM delta 299 → 607 MB).

Live gameplay (--release, Series X, 2560×1440, DLSS Quality, RT off)

  1. Default buffers=3, FG off (~5 min, intro + ~9.9k-draw indoor room):
    • Log confirmed swap chain: ... buffers=3 tearing=true; F1 menu displays SWAP CHAIN BUFFERS < 3 (TRIPLE) >.
    • In-world (~6.9k median draws): 27.9 fps median (33.9 peak); heavy room (~9.9k median draws): 27.7 fps median (29.9 peak), frame times 34.3 ms med / 45.5 ms p95 / 79.1 ms p99 (53 frames >100 ms). 0 crashes, 0 OOM, 0 refused presents.
  2. Default buffers=3, DLSS 2× Frame Generation ON (-FrameGen -FrameGenX 2, ~5 min):
    • Confirmed Streamline: our swap chain is Streamline's proxy + DLSS Frame Generation switched ... on=true times=2 code=0 result="ok".
    • 5,968 gameplay presents with 2× FG active (11,816 frames shown, 0 non-zero status codes, 0 Streamline present errors, presenting thread ~0.85 ms in Present / 3.1 ms longest).
    • Heavy room (~10.1k median draws): 24.5–27.0 base fps → ~54 fps shown (VRAM 11.5 / 13.8 GB, p95 46.4 ms, p99 69.8 ms, 25 frames >100 ms), smooth and fluid with no flicker, black frames, or crashes.

Not tested

  • Same-build live VICTORY_SWAP_BUFFERS=2 A/B (compared only against an earlier v2026.11.28.01 buffers=2 run), FSR 3 swap-chain path, VICTORY_SWAP_BUFFERS=4, and live window-resize (ResizeBuffers) stress. (cargo xtask policy hit the pre-existing bindings.ini failure on main.)

AI-assisted test run and summary.

**@⁠Bj0rnis** on GitHub · 2026-11-28 16:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1193#issuecomment-7242658870) Verified **`686a0fd0`** on **RTX 5070 Ti 16 GB** (Blackwell, driver `621.24`, Streamline `2.14.16` / NGX `310.9.16`) + **Ryzen 7 9800X3D**, 32 GB RAM, Windows 11 (`Rust 1.98.1`). ### Automated checks - **`git merge-tree` vs `origin/main` (`9ce3cf9`):** clean. - **`cargo test --locked -p victory-gpu --features diagnostics --lib` (RTX 5070 Ti):** **508 passed, 0 failed, 36 ignored** (including `host::swap_buffers_tests::defaults_to_triple_and_clamps_range`). - **`cargo clippy --locked -p victory-gpu --tests`:** **0 new warnings** (only pre-existing `shadow.rs:1708` `manual_is_multiple_of`). - **`victory.exe upscaler-check --device --present`** (`2560×1440` DLSS Quality + 2× FG): - **Default (`buffers=3`):** **180/180** FG presents, **360** frames shown, `status 0x0`, clean shutdown (swap-chain VRAM delta `299 → 622 MB`, **+15 MB** vs double buffering). - **`VICTORY_SWAP_BUFFERS=2`:** **180/180** FG presents, **360** frames shown, `status 0x0`, clean shutdown (swap-chain VRAM delta `299 → 607 MB`). ### Live gameplay (`--release`, Series X, `2560×1440`, DLSS Quality, RT off) 1. **Default `buffers=3`, FG off (~5 min, intro + ~9.9k-draw indoor room):** - Log confirmed `swap chain: ... buffers=3 tearing=true`; F1 menu displays `SWAP CHAIN BUFFERS < 3 (TRIPLE) >`. - In-world (`~6.9k` median draws): **27.9 fps** median (`33.9` peak); heavy room (`~9.9k` median draws): **27.7 fps** median (`29.9` peak), frame times `34.3 ms` med / `45.5 ms` p95 / `79.1 ms` p99 (`53` frames `>100 ms`). `0` crashes, `0` OOM, `0` refused presents. 2. **Default `buffers=3`, DLSS 2× Frame Generation ON (`-FrameGen -FrameGenX 2`, ~5 min):** - Confirmed `Streamline: our swap chain is Streamline's proxy` + `DLSS Frame Generation switched ... on=true times=2 code=0 result="ok"`. - **5,968** gameplay presents with 2× FG active (**11,816** frames shown, **0** non-zero status codes, **0** Streamline present errors, presenting thread `~0.85 ms` in `Present` / `3.1 ms` longest). - Heavy room (`~10.1k` median draws): `24.5–27.0` base fps → **~54 fps shown** (`VRAM 11.5 / 13.8 GB`, `p95 46.4 ms`, `p99 69.8 ms`, `25` frames `>100 ms`), smooth and fluid with no flicker, black frames, or crashes. ### Not tested - Same-build live `VICTORY_SWAP_BUFFERS=2` A/B (compared only against an earlier `v2026.11.28.01` `buffers=2` run), FSR 3 swap-chain path, `VICTORY_SWAP_BUFFERS=4`, and live window-resize (`ResizeBuffers`) stress. (`cargo xtask policy` hit the pre-existing `bindings.ini` failure on `main`.) *AI-assisted test run and summary.*
github-bot closed this pull request 2026-11-28 21:31:27 +00:00

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!1193
No description provided.