perf(gpu): low-latency join fast-kick/signal-stop and DXGI waitable swap chain #18

Closed
github-bot wants to merge 1 commit from gh-pr/18/head into gh-pr/18/base
Owner

@⁠justadudeinbulgaria on GitHub · 2026-11-30 23:19 UTC · original
justadudeinbulgaria:pr/low-latency-join-and-swapchain → main · +269 −28 · 3 files · 1 commits · closed without merging

Summary

Adds two opt-in, default-off low-latency frame-pacing controls targeting GPU-idle bubbles and multi-frame input lag:

  1. VICTORY_JOIN_LOW_LATENCY=1 (crates/victory-gpu/src/queue/behind.rs, crates/victory-gpu/src/host.rs):
    • Exposes lock-free host::card_busy() (LAST_SENT_FENCE vs non-blocking ID3D12Fence::GetCompletedValue()).
    • In Job::take_along, stops absorbing additional Job::Run parts when the GPU currently has zero flights in flight (immediate idle-GPU fast-kick) or once a Job::Signal has been attached to the current batch (so title threads waiting on early-part fences wake up immediately instead of stalling behind subsequent joined parts).
    • Logs per-frame idle-GPU fast-kicks and signal-boundary stops in behind::line when active.
  2. VICTORY_MAX_FRAME_LATENCY=1..16 (crates/victory-gpu/src/host.rs, crates/victory-gpu/src/frame.rs):
    • Creates the swap chain with DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT (passing matching flags to ResizeBuffers, and falling back automatically without the flag if a proxy swap chain declines it), calls IDXGISwapChain2::SetMaximumFrameLatency(n), and pairs WaitForSingleObject(waitable, 250) 1:1 with Present via LATENCY_WAIT_ARMED in frame::wait(ORIGIN) so input sampling aligns to display availability without risking stalls on un-presented boot/loading frames.

Verification

  • Unit tests: cargo test --release -p victory-gpu --lib latency_swapchain_tests (1/1) & queue::behind::tests (6/6) pass.
  • Live A/B on RTX 2060 SUPER 8 GB + i5-10600K (6,900-draw highway, DLSS Performance + AMD FSR 3 FG 2x):
    • AMD FSR 3 proxy swap chain accepted waitable=true, max_frame_latency=1 with 100% frame generation (0 prepare failures).
    • VICTORY_JOIN_LOW_LATENCY=1 fired 0.5–0.9 idle-GPU fast-kicks and 5.0–7.1 signal-boundary stops per frame.
    • Combined with VICTORY_SUBMIT_FRAMES=1, VICTORY_JOIN_PARTS=6: GPU utilization rose from 63–71% to 82%, frame time dropped from 110–118 ms to 104.5 ms (MAX 107 ms, 2.5 ms jitter), and end-to-end input queue depth dropped by >2.5x.
**@⁠justadudeinbulgaria** on GitHub · 2026-11-30 23:19 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/18) `justadudeinbulgaria:pr/low-latency-join-and-swapchain` → `main` · +269 −28 · 3 files · 1 commits · closed without merging ## Summary Adds two opt-in, default-off low-latency frame-pacing controls targeting GPU-idle bubbles and multi-frame input lag: 1. **`VICTORY_JOIN_LOW_LATENCY=1`** (`crates/victory-gpu/src/queue/behind.rs`, `crates/victory-gpu/src/host.rs`): - Exposes lock-free `host::card_busy()` (`LAST_SENT_FENCE` vs non-blocking `ID3D12Fence::GetCompletedValue()`). - In `Job::take_along`, stops absorbing additional `Job::Run` parts when the GPU currently has zero flights in flight (immediate idle-GPU fast-kick) or once a `Job::Signal` has been attached to the current batch (so title threads waiting on early-part fences wake up immediately instead of stalling behind subsequent joined parts). - Logs per-frame `idle-GPU fast-kicks` and `signal-boundary stops` in `behind::line` when active. 2. **`VICTORY_MAX_FRAME_LATENCY=1..16`** (`crates/victory-gpu/src/host.rs`, `crates/victory-gpu/src/frame.rs`): - Creates the swap chain with `DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT` (passing matching flags to `ResizeBuffers`, and falling back automatically without the flag if a proxy swap chain declines it), calls `IDXGISwapChain2::SetMaximumFrameLatency(n)`, and pairs `WaitForSingleObject(waitable, 250)` 1:1 with `Present` via `LATENCY_WAIT_ARMED` in `frame::wait(ORIGIN)` so input sampling aligns to display availability without risking stalls on un-presented boot/loading frames. ## Verification - Unit tests: `cargo test --release -p victory-gpu --lib latency_swapchain_tests` (1/1) & `queue::behind::tests` (6/6) pass. - Live A/B on RTX 2060 SUPER 8 GB + i5-10600K (6,900-draw highway, DLSS Performance + AMD FSR 3 FG 2x): - AMD FSR 3 proxy swap chain accepted `waitable=true, max_frame_latency=1` with 100% frame generation (`0` prepare failures). - `VICTORY_JOIN_LOW_LATENCY=1` fired `0.5–0.9` idle-GPU fast-kicks and `5.0–7.1` signal-boundary stops per frame. - Combined with `VICTORY_SUBMIT_FRAMES=1`, `VICTORY_JOIN_PARTS=6`: GPU utilization rose from `63–71%` to `82%`, frame time dropped from `110–118 ms` to `104.5 ms` (`MAX 107 ms`, `2.5 ms` jitter), and end-to-end input queue depth dropped by >2.5x.
Add two opt-in low-latency frame-pacing improvements (both off by default):

1. VICTORY_JOIN_LOW_LATENCY=1 (queue/behind.rs, host.rs): exposes lock-free host::card_busy() (LAST_SENT_FENCE vs GetCompletedValue) so Job::take_along stops joining extra Job::Run parts whenever the GPU is idle (immediate fast-kick, cutting the idle-GPU bubble behind victory-submit) or once a Job::Signal has been attached to the current batch (waking title threads waiting on early-part fences immediately).
2. VICTORY_MAX_FRAME_LATENCY=1..16 (host.rs, frame.rs): creates a DXGI waitable swap chain (DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT + SetMaximumFrameLatency, with automatic fallback if a proxy swap chain declines it, and matching ResizeBuffers flags), paired 1:1 with Present via LATENCY_WAIT_ARMED in frame::wait(ORIGIN). Verified active on AMD FSR 3 Frame Generation (waitable=true, max_frame_latency=1).

Live A/B on RTX 2060 SUPER 8 GB + i5-10600K raised GPU util from 63-71% to 82%, flattened frametime to 104.5 ms (MAX 107 ms), and cut end-to-end input queue depth by >2.5x.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 17:08:53 +00:00
github-bot closed this pull request 2026-12-02 17:08:53 +00:00
Author
Owner

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

Integrated into \main\ in commit \64f4cb9\ (with \Co-authored-by\ attribution).

Both \VICTORY_JOIN_LOW_LATENCY=1\ and \VICTORY_MAX_FRAME_LATENCY=1..16\ remain opt-in (off by default). Verified on RTX 3060 12 GB (\rrors=0, \mem_pressure=0, \mean_fps=15.12, \median_fps=15.09, \p99_ms=108.4, \19.4\ signal-boundary breaks/frame) and via \ ictory-gpu\ unit tests (\ rame::\ \2 passed, \queue::behind::\ \6 passed).

**@⁠ToLIManl** on GitHub · 2026-12-01 00:47 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/18#issuecomment-7296749100) Integrated into \main\ in commit \64f4cb9\ (with \Co-authored-by\ attribution). Both \VICTORY_JOIN_LOW_LATENCY=1\ and \VICTORY_MAX_FRAME_LATENCY=1..16\ remain opt-in (off by default). Verified on RTX 3060 12 GB (\rrors=0\, \mem_pressure=0\, \mean_fps=15.12\, \median_fps=15.09\, \p99_ms=108.4\, \19.4\ signal-boundary breaks/frame) and via \ ictory-gpu\ unit tests (\ rame::\ \2 passed\, \queue::behind::\ \6 passed\).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.