fix(vk): keep NVIDIA Reflex's calls with the row Off, low latency off #3254
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3254
Loading…
Reference in a new issue
No description provided.
Delete branch "Veix/Longshot:fix/reflex-off-paced"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
With NVIDIA Reflex Off, frame generation no longer stalls the renderer: Off now keeps Reflex's calls running with low latency off, as NVIDIA's Reflex guide asks. RTX 4070 SUPER, DLSS FG 2x at 4K DLSS Quality: 104 -> 128 shown fps, 51.9 -> 64.1 real fps, 1% low 18.3 -> 49.9, frames over 25 ms 501 -> 1. The built-in frame generation gains the same.
With the Reflex row Off,
vk_reflex.cppmade the swapchain without latency mode and set no markers, no present ids and no sleep. NVIDIA's Reflex programming guide (Streamline, ProgrammingGuideReflex.md) asks for the opposite, always and not only with frame generation: "slReflexSleepandslPCLSetMarkermust always be called even when Reflex Low Latency mode is Off"; the application "should always callslReflexSleepandslPCLSetMarker… without any explicit checks for user enablement, or GPU hardware/vendor/driver version"; its checklist has "slReflexSleepis called regardless of Reflex Low Latency mode state" and "PCL Markers are always sent regardless of Reflex Low Latency mode state", and its test step "Turn Reflex to Off" expects the sleep still called and the markers still updating. The guide names no operating system; this file calls the same driver entry points throughVK_NV_low_latency2, so Off follows the rule on every NVIDIA driver that has the extension.Without them NVIDIA's driver holds
vkQueuePresentKHRwith frame generation on, up to ~200 ms, with DLSS FG and with the built-in one alike. Our presents holddev.present_muacross that call, so the recorder's submits wait behind it (the log'srecorder:line: up to 3.9 s of every 10 s blocked on the queue's lock), the render thread waits for the recorder at the hand-off before DLSS's evaluate, the game's upscale reaches the GPU late, and the game waits at its frame limiter. The presents blocked with their copy into the window already done (RX_VK_PRESENT_PROBE), in a window and in fullscreen alike.To see it on
main: an NVIDIA GPU, Frame generation Fixed 2x (DLSS FG or Built-in), NVIDIA Reflex Off, V-Sync Off, Castle Town. The log'srecorder:line shows seconds of every 10 blocked on the queue's lock, and the frame rate is well below Reflex On's.engaged,off_paced,gpu/vk/vk_reflex.cpp): with the row Off the swapchain is still made in latency mode, and the markers, present ids and sleep run each frame as with the row on;apply_modegives the sleep modelowLatencyModeandlowLatencyBoostoff, so the driver does not pace the game.RX_VK_REFLEX_OFF_PACED(kill, on;=0: Off as onmain), with its row ingpu/vk/switches.def.dlssg_active); GPUs withoutVK_NV_low_latency2(AMD, Intel, older NVIDIA drivers).vk: NVIDIA Reflex: offwith the row Off (See #1268).Read first:
engagedandonat the top ofgpu/vk/vk_reflex.cpp, and the file's header comment.Written with AI assistance (Claude); the commits carry
Co-Authored-By:trailers.Testing
Tested: Windows 11, RTX 4070 SUPER, driver 621.24, Ryzen 9 9900X: the walking route (market, castle, market), windowed, 4K output, DLSS Quality, Frame generation Fixed 2x (DLSS FG, then Built-in), NVIDIA Reflex Off, V-Sync Off, Skip Upscaler Wait on. With the calls kept the
recorder:line's time blocked on the queue's lock went from 0.3-3.9 s of every 10 s to 0.01-0.12 s, and the log saysvk: NVIDIA Reflex: off. The picture as before (by eye). With DLSS FG and Skip Upscaler Wait off: 62.8 real fps, 127 shown, 0 frames over 25 ms (on: 64.1, 128, 1).tests/test_reflex_swapchain_lifetime.pyruns its fixture twice, withRX_VK_REFLEX_OFF_PACEDunset and at0, each told what it expects: with the row Off the sleep and its two markers run, a queue submit is tagged with its frame, the swapchain is made in latency mode (reflex_swapchain_info) and is not stale with the calls kept; none of it at0. Planted bugs fail it:engagedneeding the row on again (exit 32), the swapchain made without latency mode with the row Off (exit 37), the switch's default at off (exit 36). The checks for the changed files pass;tests/test_dlssg.pyfails the same way onmain@7bc53f841("vk_draw.cpp reads the Upscaler row's setting").Still to test:
recorder:line's time blocked on the queue's lock under ~0.2 s of every 10 s and no lower FPS thanRX_VK_REFLEX_OFF_PACED=0(by hand).RX_VK_REFLEX_OFF_PACED=0(by hand).VK_NV_low_latency2: the same as the first item (by hand).Measurements
Verdict: with frame generation and Reflex Off, +23 % real frames, +16-23 % shown frames, and the slow frames gone; without frame generation no cost (92.0 -> 94.1 fps).
Setup: Windows 11, RTX 4070 SUPER, driver 621.24, Ryzen 9 9900X, 64 GB; the walking route, windowed, 4K output, DLSS Quality, Frame generation Fixed 2x, NVIDIA Reflex Off, V-Sync Off, uncapped; the second market stay from 5 s after its entry. One run each.
Baseline: this PR's build with
RX_VK_REFLEX_OFF_PACED=0, which is main's Off line for line (the switch only chooses between the twoengagedresults); one build keeps everything else equal. Shown fps: the frame-generation log line's frames shown per 5 s, the median over the stay.b33a9c3dc,RX_VK_REFLEX_OFF_PACED=0)b33a9c3dcRisks
With the Reflex row Off on an NVIDIA GPU, the driver now gets Reflex's markers and sleep calls with low latency off, as NVIDIA's guide asks for Off; the sleep returns at once in that mode.
RX_VK_REFLEX_OFF_PACED=0brings back Off as onmain. Reflex On and On + Boost, Streamline's DLSS FG and GPUs withoutVK_NV_low_latency2run as before. Nothing changes in the saved settings.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, RTX 4070 SUPER, driver 621.24: the walking route at 4K DLSS Quality with Frame generation 2x (DLSS FG and Built-in), Reflex Off; the queue-lock stalls gone, 51.9 -> 64.1 real fps with DLSS FG, picture unchanged
@review
Recommendation: Approve. The reported RTX 4070 SUPER run shows a large reduction in frame-generation stalls, but it is a single run per side. The new default also changes Reflex Off without frame generation and on other NVIDIA systems, where its cost remains unmeasured. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
Reflex Off now keeps the latency-mode swapchain, markers, present IDs and sleep calls while leaving low-latency mode off. This substantially improved the reported frame-generation run, at the cost of additional driver calls and synchronization on every supported NVIDIA Reflex setup.
Should fix (1): not blocking, but worth doing before merging.
tests/test_reflex_swapchain_lifetime.py:114: The test derives its expected default from the same function it is testing, so it does not protect the switch's default. (more on the line) Do: Pass the expected switch state to each fixture run and assert it independently of off_paced(); also exercise reflex_swapchain_info with the row Off.Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_reflex.cpp:99: The reported frame-generation gain needs repeated interleaved measurements against the base. (more on the line) Do: Repeat the same warmed-up route with at least two interleaved runs each on the base and this head, reporting individual runs and medians for both frame-generation implementations.gpu/vk/vk_reflex.cpp:99: The default adds driver calls and a semaphore wait even when frame generation is off, a much broader case than the reported fix. (more on the line) Do: Compare base and head in the market with frame generation and Reflex Off on Windows, including frame times and input latency where practical. (@fixdoes its part first: Limit the new path to frame-generation configurations if the calls are unnecessary without frame generation.)gpu/vk/vk_reflex.cpp:99: The new default has not been exercised on Linux NVIDIA drivers or an RTX 50 GPU. (more on the line) Do: Run the documented Reflex Off frame-generation comparisons on Linux NVIDIA and Windows RTX 50, covering DLSS and built-in frame generation where supported, and report frame times and visual behavior.@fixcan do L1 and L3.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven across repeated runs. On one Windows RTX 4070 SUPER run per side, DLSS FG improved from 51.9 to 64.1 real fps and its 1% low from 18.3 to 49.9; built-in FG improved from 65.5 to 76.4 real fps. The baseline was this head with the new switch disabled, rather than a separate base build.
Other systems: The default also affects NVIDIA Reflex Off with frame generation disabled, Linux NVIDIA drivers, and swapchain creation while Streamline DLSS FG is active. AMD, Intel and devices without the required extensions do not engage the new path. On and Boost retain their existing call path. The submitted evidence covers Windows RTX 4070 SUPER with frame generation, but not the other affected configurations.
Switches: RX_VK_REFLEX_OFF_PACED is added as a kill switch, default on; 0 restores the previous Off behavior. It has a switches.def row. The default has promising results on one Windows GPU, but its cost without frame generation and on other supported NVIDIA systems is not yet measured.
Reviewed:
b33a9c3dcfagainst7bc53f8413: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the full vk_reflex.cpp and test_reflex_swapchain_lifetime.py, the diff and commit, and relevant swapchain, presenter and Streamline callers. Skimmed switches.def and other tests that read vk_reflex.cpp. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No recorded runs, translations or generated files changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code, scripts, builds or tests were run. CI is still running.
Overlaps and merge order: Unknown; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by Veix. Nothing was run; a maintainer decides.
@ -92,0 +96,4 @@bool off_paced() {static const bool v = env_on_or("RX_VK_REFLEX_OFF_PACED", 1);return v;}L2 (should fix): The reported frame-generation gain needs repeated interleaved measurements against the base.
When: The 4070 SUPER results have one run per side, so route and run-to-run variation are not represented in the claimed gain or the slow-frame counts.
Do: Repeat the same warmed-up route with at least two interleaved runs each on the base and this head, reporting individual runs and medians for both frame-generation implementations.
L3 (should fix): The default adds driver calls and a semaphore wait even when frame generation is off, a much broader case than the reported fix.
When: An NVIDIA player with Reflex and frame generation Off now enters the latency path every frame; the submitted runs do not show its effect on frame time or input latency in that configuration.
Do: Compare base and head in the market with frame generation and Reflex Off on Windows, including frame times and input latency where practical.
L4 (should fix): The new default has not been exercised on Linux NVIDIA drivers or an RTX 50 GPU.
When: Those systems take the same newly enabled swapchain and per-frame driver path, but the Windows RTX 4070 SUPER result cannot show whether their pacing and output remain correct.
Do: Run the documented Reflex Off frame-generation comparisons on Linux NVIDIA and Windows RTX 50, covering DLSS and built-in frame generation where supported, and report frame times and visual behavior.
@ -108,8 +111,10 @@ void reset(){void retire_before_lock(){reflex_swapchain_destroyed();}int main(){reset();reflex_sleep();if(invalid||markers!=2||sleeps!=1||!state.frame_marked)return 1;const bool paced=off_paced(); // (RX_VK_REFLEX_OFF_PACED: unset or 1 the row Off still marks and sleeps)L1 (should fix): The test derives its expected default from the same function it is testing, so it does not protect the switch's default.
When: If off_paced() changes its env_on_or default from 1 to 0, both fixture runs set paced to false and all the conditional Off assertions still pass, even though the default no longer fixes the reported stall.
Do: Pass the expected switch state to each fixture run and assert it independently of off_paced(); also exercise reflex_swapchain_info with the row Off.
L1: done in
06efb0239: each fixture run is told the switch state it expects (the default at off now fails it, exit 36), andreflex_swapchain_infois checked with the row Off (the old rule fails it, exit 37).L2: the gap is far beyond run-to-run noise on this route (the means of one setting hold to about 0.01 ms between runs), and every combination we ran shows it the same way, on two builds:
mainWith the calls kept the recorder's time blocked on the queue's lock fell from 0.3-3.9 s of every 10 s to 0.01-0.12 s in each frame-generation run. For comparison, Reflex On + Boost on #3212's build: 65.5 fps, 0 frames over 25 ms: Off now matches it.
L3: NVIDIA's guide asks for the calls always, not only with frame generation ("without any explicit checks for user enablement, or GPU hardware/vendor/driver version", linked in the description), so the path stays for every Reflex Off. Without frame generation it costs nothing measurable (92.0 -> 94.1 fps, 1% low 59.3 -> 60.9).
L4: under Still to test (Linux NVIDIA, RTX 50).
@review
Recommendation: Approve. The code is ready: only testing is left. The reported frame-generation improvement is substantial, but repeated interleaved measurements and the Linux and RTX 50 runs are still needed before choosing the new default for all affected players. Recommend approval; not approved on the forge.
Keeps Reflex markers, present IDs and sleep calls active with low latency disabled when the Reflex row is Off. The reported Windows run shows much shorter frame-generation stalls, at the cost of additional driver calls and a semaphore wait even without frame generation.
Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_reflex.cpp:99: The reported frame-generation gain needs repeated interleaved measurements against the base. When: The 4070 SUPER results have one run per side, so route and run-to-run variation are not represented in the claimed gain or the slow-frame counts. Do: Repeat the same warmed-up route with at least two interleaved runs each on the base and this head, reporting individual runs and medians for both frame-generation implementations.gpu/vk/vk_reflex.cpp:99: The default adds driver calls and a semaphore wait even when frame generation is off, a much broader case than the reported fix. When: An NVIDIA player with Reflex and frame generation Off now enters the latency path every frame; the submitted runs do not show its effect on frame time or input latency in that configuration. Do: Compare base and head in the market with frame generation and Reflex Off on Windows, including frame times and input latency where practical. (@fixdoes its part first: Limit the new path to frame-generation configurations if the calls are unnecessary without frame generation.)gpu/vk/vk_reflex.cpp:99: The new default has not been exercised on Linux NVIDIA drivers or an RTX 50 GPU. When: Those systems take the same newly enabled swapchain and per-frame driver path, but the Windows RTX 4070 SUPER result cannot show whether their pacing and output remain correct. Do: Run the documented Reflex Off frame-generation comparisons on Linux NVIDIA and Windows RTX 50, covering DLSS and built-in frame generation where supported, and report frame times and visual behavior.@fixcan do L3.Since the last review (on
b33a9c3dcf)Resolved: L1 (The test derives its expected default from the same function it is testing, so it does not…)
Still open: L2 (The reported frame-generation gain needs repeated interleaved measurements against the bas…); L3 (The default adds driver calls and a semaphore wait even when frame generation is off, a mu…); L4 (The new default has not been exercised on Linux NVIDIA drivers or an RTX 50 GPU.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: on one Windows RTX 4070 SUPER run, DLSS FG improved from 51.9 to 64.1 real fps and frames over 25 ms fell from 501 to 1; built-in FG improved from 65.5 to 76.4 fps. The PR reports one run per setting rather than repeated interleaved runs.
Other systems: The new default affects NVIDIA drivers supporting VK_NV_low_latency2 on Windows and Linux. Linux and RTX 50 behavior remain untested; GPUs without the extension and Streamline's active DLSS FG path are guarded separately.
Switches: RX_VK_REFLEX_OFF_PACED is added as a developer kill switch, default on; 0 restores the previous Off behavior. The default's broader performance and hardware effects still need the listed runs.
Reviewed:
06efb02396against7bc53f8413: Read the changed test and its incremental diff, the Reflex change and its callers, repository guidance and pull request template. The large switches.def and surrounding renderer files were skimmed; no generated files or recorded runs were supplied for review.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run. The author reports an in-game Windows RTX 4070 SUPER test; CI is still running.
Overlaps and merge order: None found in the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by Veix. Nothing was run; a maintainer decides.
Two more combinations on the same build (06efb0239's code;
RX_VK_REFLEX_OFF_PACED=0for main's Off), the walking route, windowed, 4K DLSS Quality, Reflex Off, the second market stay from 5 s after its entry.Without frame generation, two pairs: no cost; the fix is slightly ahead in both.
main(pair 1 / 2)Built-in frame generation at 4x (DLSS FG makes at most one frame between two of the game's on this RTX 4070 SUPER):
main