FSR 3 frame generation: the presenter sleeps and waits for its fence instead of spinning (VICTORY_FSR_PACING) #2371

Open
Sil3ntGam3r wants to merge 1 commit from upstream-pr/2371 into main
Sil3ntGam3r commented 2026-11-29 12:26:20 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Sil3ntGam3r on 2026-11-29T12:26:20Z.


With FSR 3 frame generation on, FidelityFX's frame interpolation swap chain uses its default frame pacing. With those
defaults it spins until the next present is due, and spins again on the fence. On a CPU-bound 6-core machine, that
spinning takes almost a whole logical processor from the threads the frame waits on.

This PR sets FfxApiSwapchainFramePacingTuning on the swap chain context right after it is made. It is sent through
ffxConfigureDescFrameGenerationSwapChainKeyValueDX12 (type 0x30008) with key FRAMEPACINGTUNING (2):

  • allowHybridSpin = true with hybridSpinTime = 2: it sleeps and only spins the last two timer ticks.
    victory-hle's timeBeginPeriod(1) makes a tick 1 ms.
  • allowWaitForSingleObjectOnFence = true: it waits on the fence with WaitForSingleObject instead of spinning.

safetyMarginInMs and varianceFactor keep FidelityFX's values (0.1 / 0.1). In the SDK header, both flags default
to false.

VICTORY_FSR_PACING is a list of hybrid and fence, both when unset. VICTORY_FSR_PACING=spin keeps
FidelityFX's defaults, which is the behaviour before this PR. The configure call's return code is logged. Only the
FSR 3.x swap chain is configured. FSR 4's 4.0.0 swap-chain provider is left as it is because I couldn't test it.

Measured on an RTX 3070 8 GB (driver 621.40) with an i5-11600K (6 cores / 12 threads), Windows 11. Series S
profile, DLSS Quality, FSR 3 frame generation 2x, the same save and spot in the open world, release builds, 30 s of
per-thread CPU time (QueryThreadCycleTime):

default (spin) hybrid + fence
AMD FSR Presenter Thread 61.3 % of a processor 19.5 %
FSR interpolation thread 45.6 % under 14 %
whole process 853 % 765 %
rendered fps 20.45 20.90

Before the fix, a world timeline showed the presenter thread at 31–40 ms of every ~35 ms frame. It sat alongside
victory-submit (33–40 ms) and the four list threads (27–36 ms each). In a second pair of runs, it was 21.15 fps
against 20.89. Between runs on this machine, the noise is about ±0.5 fps. So the frame-rate gain on its own is
small. The clear result is about 0.9 of a logical processor given back, which should matter more on 4- and 6-core
CPUs.

Those numbers are from main a4d05e7f plus local tuning. I ran two 15-minute runs in the world with it on: no crash,
no device removal, interpolated frames at 2x the rendered rate.

On this branch (829188e9 + this PR), the same machine and settings, four alternating runs of about 5 minutes
in the world each: two on (unset), two off (VICTORY_FSR_PACING=spin). Each run took 30 s of thread times after
about 2 minutes in the world. FidelityFX answered code=0 both times it was on.

spin, run 1 spin, run 2 hybrid + fence, run 1 hybrid + fence, run 2
AMD FSR Presenter Thread 54.6 % 42.8 % 20.9 % 18.5 %
AMD FSR Interpolation Thread 37.7 % 33.8 % under 16 % 14.2 %
whole process 887 % 875 % 830 % 815 %
rendered fps, mean (median) 20.30 (20.80) 20.15 (20.40) 20.21 (20.40) 20.37 (21.10)

So on main it gives back about 0.6 of a processor, and the presenter and interpolation threads drop by more than
half. Rendered fps here was the same either way (20.23 against 20.29 on average). On this machine the frame still
waits on victory-submit (71–80 % of a processor) and the list threads, so the freed time isn't what limits it.
CPUs with fewer cores, or machines with other things running, are where this should show.

Tested:

  • cargo test --workspace --locked --no-fail-fast: 2,162 passed and 7 failed. The same tests fail on 829188e9
    without this PR: three BCPack oracle_parity_* tests in victory-formats, xmem::...a_read_by_range_waits...
    in victory-hle, xtask's repository_passes_policy (it flags victory-loader/src/heap_sites/frame_users.rs) and
    host::menu::tests::a_change_is_saved_at_once.... One more victory-gpu test failed in each full run:
    card_steps::places_written_after_sending_are_learned on main, menu::gray_shadow_lift_is_live... on this
    branch. Both pass when run alone (3 of 3), so they look order-dependent.
  • cargo test -p victory-gpu fsr: 9 passed, including new layout checks: SwapChainKeyValue is 40 bytes and
    PacingTuning is 20, with hybrid_spin_time at offset 12 and the fence flag at 16.
  • cargo clippy adds no warnings in fsr.rs. Note that on 829188e9 itself, cargo clippy --workspace --all-targets -- -D warnings already fails in code this PR doesn't touch: victory-loader/src/crash.rs:804
    unwind_copy is unused, and victory-shader/src/emit/lower/analysis.rs:6 / :467 and emit/lower.rs:594 have an
    unused import and while_immutable_condition.

AI-assisted (Claude Code); tested on the hardware above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5550689034 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2371). Originally posted by [Sil3ntGam3r](https://github.com/Sil3ntGam3r) on 2026-11-29T12:26:20Z. --- With FSR 3 frame generation on, FidelityFX's frame interpolation swap chain uses its default frame pacing. With those defaults it spins until the next present is due, and spins again on the fence. On a CPU-bound 6-core machine, that spinning takes almost a whole logical processor from the threads the frame waits on. This PR sets `FfxApiSwapchainFramePacingTuning` on the swap chain context right after it is made. It is sent through `ffxConfigureDescFrameGenerationSwapChainKeyValueDX12` (type `0x30008`) with key `FRAMEPACINGTUNING` (2): - `allowHybridSpin = true` with `hybridSpinTime = 2`: it sleeps and only spins the last two timer ticks. victory-hle's `timeBeginPeriod(1)` makes a tick 1 ms. - `allowWaitForSingleObjectOnFence = true`: it waits on the fence with `WaitForSingleObject` instead of spinning. `safetyMarginInMs` and `varianceFactor` keep FidelityFX's values (0.1 / 0.1). In the SDK header, both flags default to false. `VICTORY_FSR_PACING` is a list of `hybrid` and `fence`, both when unset. `VICTORY_FSR_PACING=spin` keeps FidelityFX's defaults, which is the behaviour before this PR. The configure call's return code is logged. Only the FSR 3.x swap chain is configured. FSR 4's 4.0.0 swap-chain provider is left as it is because I couldn't test it. **Measured** on an RTX 3070 8 GB (driver 621.40) with an i5-11600K (6 cores / 12 threads), Windows 11. Series S profile, DLSS Quality, FSR 3 frame generation 2x, the same save and spot in the open world, release builds, 30 s of per-thread CPU time (QueryThreadCycleTime): | | default (spin) | hybrid + fence | |---|---|---| | AMD FSR Presenter Thread | 61.3 % of a processor | 19.5 % | | FSR interpolation thread | 45.6 % | under 14 % | | whole process | 853 % | 765 % | | rendered fps | 20.45 | 20.90 | Before the fix, a world timeline showed the presenter thread at 31–40 ms of every ~35 ms frame. It sat alongside `victory-submit` (33–40 ms) and the four list threads (27–36 ms each). In a second pair of runs, it was 21.15 fps against 20.89. Between runs on this machine, the noise is about ±0.5 fps. So the frame-rate gain on its own is small. The clear result is about 0.9 of a logical processor given back, which should matter more on 4- and 6-core CPUs. Those numbers are from main `a4d05e7f` plus local tuning. I ran two 15-minute runs in the world with it on: no crash, no device removal, interpolated frames at 2x the rendered rate. **On this branch (`829188e9` + this PR)**, the same machine and settings, four alternating runs of about 5 minutes in the world each: two on (unset), two off (`VICTORY_FSR_PACING=spin`). Each run took 30 s of thread times after about 2 minutes in the world. FidelityFX answered `code=0` both times it was on. | | spin, run 1 | spin, run 2 | hybrid + fence, run 1 | hybrid + fence, run 2 | |---|---|---|---|---| | AMD FSR Presenter Thread | 54.6 % | 42.8 % | 20.9 % | 18.5 % | | AMD FSR Interpolation Thread | 37.7 % | 33.8 % | under 16 % | 14.2 % | | whole process | 887 % | 875 % | 830 % | 815 % | | rendered fps, mean (median) | 20.30 (20.80) | 20.15 (20.40) | 20.21 (20.40) | 20.37 (21.10) | So on main it gives back about 0.6 of a processor, and the presenter and interpolation threads drop by more than half. Rendered fps here was the same either way (20.23 against 20.29 on average). On this machine the frame still waits on `victory-submit` (71–80 % of a processor) and the list threads, so the freed time isn't what limits it. CPUs with fewer cores, or machines with other things running, are where this should show. **Tested:** - `cargo test --workspace --locked --no-fail-fast`: 2,162 passed and 7 failed. The same tests fail on `829188e9` without this PR: three BCPack `oracle_parity_*` tests in `victory-formats`, `xmem::...a_read_by_range_waits...` in `victory-hle`, xtask's `repository_passes_policy` (it flags `victory-loader/src/heap_sites/frame_users.rs`) and `host::menu::tests::a_change_is_saved_at_once...`. One more `victory-gpu` test failed in each full run: `card_steps::places_written_after_sending_are_learned` on main, `menu::gray_shadow_lift_is_live...` on this branch. Both pass when run alone (3 of 3), so they look order-dependent. - `cargo test -p victory-gpu fsr`: 9 passed, including new layout checks: `SwapChainKeyValue` is 40 bytes and `PacingTuning` is 20, with `hybrid_spin_time` at offset 12 and the fence flag at 16. - `cargo clippy` adds no warnings in `fsr.rs`. Note that on `829188e9` itself, `cargo clippy --workspace --all-targets -- -D warnings` already fails in code this PR doesn't touch: `victory-loader/src/crash.rs:804` `unwind_copy` is unused, and `victory-shader/src/emit/lower/analysis.rs:6` / `:467` and `emit/lower.rs:594` have an unused import and `while_immutable_condition`. AI-assisted (Claude Code); tested on the hardware above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nikitronick-crypto commented 2026-11-30 18:25:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nikitronick-crypto on 2026-11-30T18:25:02Z.


A second 6-core machine for this PR, where it does move the frame.

Ryzen 5 7500F (6c/12t), RTX 3080 Ti 12 GB, 32 GB DDR5-4800, Windows 11 26300, driver 621.40.
v2026.11.30.01 (c71899d9) release build, Series X, 2560x1440, DLSS Balanced, FSR 3 frame generation 2x.
This PR applies cleanly on c71899d9. FidelityFX answered code=0 hybrid=true fence=true.

Same street, standing/walking, 9,400-10,100 draws a frame, medians of the 5 s frame lines.
Frame generation was switched in the F1 menu inside each run (on -> off -> on), so on and off share a run.

c71899d9 c71899d9 + this PR
frame generation on 68.9 ms (8 lines) 62.4 ms (14 lines)
frame generation off 59.0 ms (7 lines) 56.6 ms (5 lines)
cost of frame generation, draws regressed out (3.9 ms per 1,000) ~8 ms ~4.5 ms

So on this CPU the default pacing costs about 8 ms of rendered frame time with frame generation on,
and this PR gives back 3-4 ms of it (about 14.5 -> 16 rendered fps). The two builds were separate runs,
and the run with the PR was ~2.4 ms faster with frame generation off too, which is why I count 3-4 ms
and not the full 6.5. Single lines range 57-69 ms, and the "off" segment with the PR is only 25 s.

No crash or device removal in the run; interpolated frames were at 2x the rendered rate.

Runs are from my own PC; the logs were read and this was written with an AI assistant (Claude).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7287817968 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2371#issuecomment-7287817968). Originally posted by [nikitronick-crypto](https://github.com/nikitronick-crypto) on 2026-11-30T18:25:02Z. --- A second 6-core machine for this PR, where it does move the frame. Ryzen 5 7500F (6c/12t), RTX 3080 Ti 12 GB, 32 GB DDR5-4800, Windows 11 26300, driver 621.40. v2026.11.30.01 (c71899d9) release build, Series X, 2560x1440, DLSS Balanced, FSR 3 frame generation 2x. This PR applies cleanly on c71899d9. FidelityFX answered code=0 hybrid=true fence=true. Same street, standing/walking, 9,400-10,100 draws a frame, medians of the 5 s frame lines. Frame generation was switched in the F1 menu inside each run (on -> off -> on), so on and off share a run. | | c71899d9 | c71899d9 + this PR | |---|---|---| | frame generation on | 68.9 ms (8 lines) | 62.4 ms (14 lines) | | frame generation off | 59.0 ms (7 lines) | 56.6 ms (5 lines) | | cost of frame generation, draws regressed out (3.9 ms per 1,000) | ~8 ms | ~4.5 ms | So on this CPU the default pacing costs about 8 ms of rendered frame time with frame generation on, and this PR gives back 3-4 ms of it (about 14.5 -> 16 rendered fps). The two builds were separate runs, and the run with the PR was ~2.4 ms faster with frame generation off too, which is why I count 3-4 ms and not the full 6.5. Single lines range 57-69 ms, and the "off" segment with the PR is only 25 s. No crash or device removal in the run; interpolated frames were at 2x the rendered rate. Runs are from my own PC; the logs were read and this was written with an AI assistant (Claude).
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/2371:upstream-pr/2371'
git switch 'upstream-pr/2371'

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/2371'
git switch 'upstream-pr/2371'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2371'
git switch 'upstream-pr/2371'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2371'
git switch 'main'
git merge --squash 'upstream-pr/2371'
git switch 'main'
git merge --ff-only 'upstream-pr/2371'
git switch 'main'
git merge 'upstream-pr/2371'
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
trustno1-coder/VIctory-NVIDIA!2371
No description provided.