NVIDIA Reflex: latency markers and low latency mode (Streamline PCL or NvAPI), feasibility and phases #729

Open
opened 2026-11-26 03:49:50 +00:00 by github-bot · 1 comment
Owner

@⁠Revens2 on GitHub · 2026-11-25 05:48 UTC · original

Problem

NVIDIA Reflex reduces the time between an input and the frame it changes by pacing the CPU against the GPU queue (low latency mode, an optional boost, and a sleep placed before the simulation of a frame) and by letting the driver and tools see latency markers. The title is a console game and has no Reflex calls. The fork owns the host D3D12 device, queue, present and the frame clock the title waits on, so it could add Reflex itself. This issue studies whether that is worth doing and how, in phases.

No issue or PR in this repository mentions Reflex, NvAPI or Streamline's PCL. Related upstream work (Marvisak/VIctory, not this repository):

  • Marvisak/VIctory#1704 (open): DLSS Super Resolution through the public Streamline SDK, loaded from VICTORY_DLSS_DIR; manual hooking on the host device; swap chain made through Streamline's proxy factory.
  • Marvisak/VIctory#1715 (open, stacked on #1704): DLSS frame generation. Its description says each present gets "the PCL markers and Reflex's sleep (low latency mode), which DLSS-G requires", and that without VICTORY_DLSS_FG there are no markers and no Reflex. So Reflex exists there only as a requirement of frame generation, not as a feature of its own.
  • In this repository, #616 reports a branch with Streamline 2.14.16 + DLSS on an RTX 3050 in Series S mode; it does not mention Reflex.

If #1704 is ported to this fork, Streamline will already be loaded and Reflex becomes a small addition; if not, NvAPI alone is enough. This issue should be coordinated with the upscaling issue so the two do not each load their own copy of the NVIDIA runtime.

Current state of the code (origin/main at 310c6eb)

Points where markers and a sleep could attach, all in crates/:

  • Frame start: victory-gpu/src/frame.rs, wait for event kind 0 (origin) hands out the frame token (FRAME counter) and returns when the title may start a frame. This is the natural place for a Reflex sleep, because the title already blocks there.
  • Submission: victory-gpu/src/queue.rs receives the title's command lists and executes them on the host queue; host.rs has the first/last submission of a frame (FINISHED counter, settle_now).
  • Present: host.rs, Presenter::present (copy into the back buffer, Present(0, 0)), then Meter::frame.
  • Input sample: victory-hle/src/modules/gameinput.rs reads XInput and GetAsyncKeyState in a polling loop (POLL = 8 ms) and hands the readings to the title when it asks. That is where an input marker would be taken.
  • Device and queue are host objects (Host's device and queue); nothing in the tree loads nvapi64.dll, sl.interposer.dll or any NVIDIA runtime today.

What the fork cannot see: which of the title's threads simulates, which renders, and when the simulation of frame N ends. It sees the origin wait, the command lists and the present. Markers for simulation start/end would therefore be approximations (origin wait end, first submission), not the title's real simulation window.

Two ways in

A. Streamline (PCL + Reflex plugins). Public NVIDIA SDK on GitHub; its headers are reported MIT-licensed in Marvisak/VIctory#1704's description (not re-verified here). Runtime sl.interposer.dll and plugins loaded from a user-provided folder, not shipped in the tree. Requires the Streamline initialisation and, for markers to be consumed correctly, the manual-hooking path (slSetD3DDevice, proxy swap chain), which #1704 already had to solve. Heavier, but shared with DLSS.

B. NvAPI directly. NvAPI_D3D_SetSleepMode, NvAPI_D3D_Sleep, NvAPI_D3D_SetLatencyMarker, NvAPI_D3D_GetLatency on the host device, resolved from the driver's nvapi64.dll (installed with the NVIDIA driver, so nothing to ship). Smaller and independent of upscaling. The licence of the NvAPI headers needed for bindings is not verified; a hand-written minimal binding of the few entry points (queried through nvapi_QueryInterface) avoids the question but would need review.

Both are NVIDIA-only. The host already identifies the adapter (see #261 for adapter selection, a PR); the feature must be a no-op on other vendors.

Proposal, in deliverable phases

  1. Feasibility spike, no feature: load nvapi64.dll on the host, call SetSleepMode on the host device in a test (the victory-gpu tests already create a real device), report which calls succeed on which driver. Output: a short table in this issue.
  2. Markers only (VICTORY_REFLEX=markers): input sample, simulation start (origin wait end), render submit start/end, present start/end, with the frame token as the frame id. Observable through NvAPI_D3D_GetLatency or PCLStats-compatible tools. No pacing change.
  3. Sleep (VICTORY_REFLEX=on): SetSleepMode (low latency on, boost off) and Sleep placed in frame::wait for the origin event, so the title's own wait absorbs it. Never sleep on a timed poll (timeout_ms == 0); only on the blocking wait.
  4. Interplay with the present path and any fps limit (see the frame pacing and the settings issues): Reflex's sleep and a fixed limiter fight each other; when Reflex is on, the limiter is bypassed or the user is told.
  5. If Streamline is adopted for DLSS, move the markers to PCL so frame generation can use them; keep the NvAPI path only if it has a reason to stay.

Risks

  • Latency benefit depends on the CPU running ahead of the GPU. In the world today frames take hundreds of milliseconds and the GPU is often busy for most of that (#696 splits one frame's time); a latency feature changes little at that rate and should not be sold as a fix for frame time. Not verified on any scene faster than 10 fps.
  • Marker placement is approximate (see above); wrong markers make the driver's pacing worse, not better. Phase 1 is observation only for that reason.
  • Sleeping in frame::wait changes the title's cadence. The intro movie is already sensitive to presents without a flip wait (#457, #602); movies and menus should be excluded or tested separately.
  • A driver or SDK that is missing must leave everything unchanged (log once, continue).
  • Streamline path: loading external code (the Marvisak/VIctory#1704 triage flagged this as a maintainer decision); user-provided folder only, never redistributed.
  • NVIDIA licences for Streamline/Reflex binaries and the nvapi headers are not verified; nothing in the tree may be added before that is clear.

Acceptance criteria (measurable)

  • Phase 0: a table of driver version, GPU, and the return code of each call, from at least one RTX 30/40/50-series card and a machine with no NVIDIA adapter (where the feature must report "not available" and change nothing).
  • Phase 1: with markers on, NvAPI_D3D_GetLatency (or PCLStats) returns frame reports for at least 95 % of the presented frames of a 60 s run in the menu; with VICTORY_REFLEX unset the build and behaviour are identical to main (frame count and present interval within noise).
  • Phase 2: on a scene faster than 30 fps (menu or movie are the only candidates today), median present latency (PCL or an external capture tool) is lower with Reflex on than off over three alternating 60 s runs, with the figures posted; if not lower, the issue closes as "not useful here".
  • No new device removed over a 10 minute run; cargo test --workspace --locked stays green; non-NVIDIA hosts unchanged.

Not verified

  • Anything about Reflex on this title: no run has been made.
  • That NvAPI latency markers are accepted from a process that is not a conventional D3D12 renderer (the title runs through our host device, which is ordinary D3D12; this has not been tried).
  • The licence terms of the SDKs and headers named above.
  • AMD Anti-Lag 2 and Intel equivalents (mentioned only as possible follow-ups; nothing was checked).

Next step

Phase 0 is a small spike and can be a PR of tests only. A PR will follow if the spike works; phases 1 and 2 wait for the decision on Streamline vs NvAPI.

**@⁠Revens2** on GitHub · 2026-11-25 05:48 UTC · [original](https://github.com/fxceless/victory-fork/issues/729) ## Problem NVIDIA Reflex reduces the time between an input and the frame it changes by pacing the CPU against the GPU queue (low latency mode, an optional boost, and a sleep placed before the simulation of a frame) and by letting the driver and tools see latency markers. The title is a console game and has no Reflex calls. The fork owns the host D3D12 device, queue, present and the frame clock the title waits on, so it could add Reflex itself. This issue studies whether that is worth doing and how, in phases. ## Related work (checked 2026-11-25; searches: reflex, latency, streamline, nvapi, low latency) No issue or PR in this repository mentions Reflex, NvAPI or Streamline's PCL. Related upstream work (Marvisak/VIctory, not this repository): - Marvisak/VIctory#1704 (open): DLSS Super Resolution through the public Streamline SDK, loaded from `VICTORY_DLSS_DIR`; manual hooking on the host device; swap chain made through Streamline's proxy factory. - Marvisak/VIctory#1715 (open, stacked on #1704): DLSS frame generation. Its description says each present gets "the PCL markers and Reflex's sleep (low latency mode), which DLSS-G requires", and that without `VICTORY_DLSS_FG` there are no markers and no Reflex. So Reflex exists there only as a requirement of frame generation, not as a feature of its own. - In this repository, #616 reports a branch with Streamline 2.14.16 + DLSS on an RTX 3050 in Series S mode; it does not mention Reflex. If #1704 is ported to this fork, Streamline will already be loaded and Reflex becomes a small addition; if not, NvAPI alone is enough. This issue should be coordinated with the upscaling issue so the two do not each load their own copy of the NVIDIA runtime. ## Current state of the code (`origin/main` at 310c6eb) Points where markers and a sleep could attach, all in `crates/`: - Frame start: `victory-gpu/src/frame.rs`, `wait` for event kind 0 (origin) hands out the frame token (`FRAME` counter) and returns when the title may start a frame. This is the natural place for a Reflex sleep, because the title already blocks there. - Submission: `victory-gpu/src/queue.rs` receives the title's command lists and executes them on the host queue; `host.rs` has the first/last submission of a frame (`FINISHED` counter, `settle_now`). - Present: `host.rs`, `Presenter::present` (copy into the back buffer, `Present(0, 0)`), then `Meter::frame`. - Input sample: `victory-hle/src/modules/gameinput.rs` reads XInput and `GetAsyncKeyState` in a polling loop (`POLL` = 8 ms) and hands the readings to the title when it asks. That is where an input marker would be taken. - Device and queue are host objects (`Host`'s `device` and `queue`); nothing in the tree loads `nvapi64.dll`, `sl.interposer.dll` or any NVIDIA runtime today. What the fork cannot see: which of the title's threads simulates, which renders, and when the simulation of frame N ends. It sees the origin wait, the command lists and the present. Markers for simulation start/end would therefore be approximations (origin wait end, first submission), not the title's real simulation window. ## Two ways in A. Streamline (PCL + Reflex plugins). Public NVIDIA SDK on GitHub; its headers are reported MIT-licensed in Marvisak/VIctory#1704's description (not re-verified here). Runtime `sl.interposer.dll` and plugins loaded from a user-provided folder, not shipped in the tree. Requires the Streamline initialisation and, for markers to be consumed correctly, the manual-hooking path (`slSetD3DDevice`, proxy swap chain), which #1704 already had to solve. Heavier, but shared with DLSS. B. NvAPI directly. `NvAPI_D3D_SetSleepMode`, `NvAPI_D3D_Sleep`, `NvAPI_D3D_SetLatencyMarker`, `NvAPI_D3D_GetLatency` on the host device, resolved from the driver's `nvapi64.dll` (installed with the NVIDIA driver, so nothing to ship). Smaller and independent of upscaling. The licence of the NvAPI headers needed for bindings is not verified; a hand-written minimal binding of the few entry points (queried through `nvapi_QueryInterface`) avoids the question but would need review. Both are NVIDIA-only. The host already identifies the adapter (see #261 for adapter selection, a PR); the feature must be a no-op on other vendors. ## Proposal, in deliverable phases 0. Feasibility spike, no feature: load `nvapi64.dll` on the host, call `SetSleepMode` on the host device in a test (the `victory-gpu` tests already create a real device), report which calls succeed on which driver. Output: a short table in this issue. 1. Markers only (`VICTORY_REFLEX=markers`): input sample, simulation start (origin wait end), render submit start/end, present start/end, with the frame token as the frame id. Observable through `NvAPI_D3D_GetLatency` or PCLStats-compatible tools. No pacing change. 2. Sleep (`VICTORY_REFLEX=on`): `SetSleepMode` (low latency on, boost off) and `Sleep` placed in `frame::wait` for the origin event, so the title's own wait absorbs it. Never sleep on a timed poll (`timeout_ms == 0`); only on the blocking wait. 3. Interplay with the present path and any fps limit (see the frame pacing and the settings issues): Reflex's sleep and a fixed limiter fight each other; when Reflex is on, the limiter is bypassed or the user is told. 4. If Streamline is adopted for DLSS, move the markers to PCL so frame generation can use them; keep the NvAPI path only if it has a reason to stay. ## Risks - Latency benefit depends on the CPU running ahead of the GPU. In the world today frames take hundreds of milliseconds and the GPU is often busy for most of that (#696 splits one frame's time); a latency feature changes little at that rate and should not be sold as a fix for frame time. Not verified on any scene faster than 10 fps. - Marker placement is approximate (see above); wrong markers make the driver's pacing worse, not better. Phase 1 is observation only for that reason. - Sleeping in `frame::wait` changes the title's cadence. The intro movie is already sensitive to presents without a flip wait (#457, #602); movies and menus should be excluded or tested separately. - A driver or SDK that is missing must leave everything unchanged (log once, continue). - Streamline path: loading external code (the Marvisak/VIctory#1704 triage flagged this as a maintainer decision); user-provided folder only, never redistributed. - NVIDIA licences for Streamline/Reflex binaries and the `nvapi` headers are not verified; nothing in the tree may be added before that is clear. ## Acceptance criteria (measurable) - Phase 0: a table of driver version, GPU, and the return code of each call, from at least one RTX 30/40/50-series card and a machine with no NVIDIA adapter (where the feature must report "not available" and change nothing). - Phase 1: with markers on, `NvAPI_D3D_GetLatency` (or PCLStats) returns frame reports for at least 95 % of the presented frames of a 60 s run in the menu; with `VICTORY_REFLEX` unset the build and behaviour are identical to main (frame count and present interval within noise). - Phase 2: on a scene faster than 30 fps (menu or movie are the only candidates today), median present latency (PCL or an external capture tool) is lower with Reflex on than off over three alternating 60 s runs, with the figures posted; if not lower, the issue closes as "not useful here". - No new `device removed` over a 10 minute run; `cargo test --workspace --locked` stays green; non-NVIDIA hosts unchanged. ## Not verified - Anything about Reflex on this title: no run has been made. - That NvAPI latency markers are accepted from a process that is not a conventional D3D12 renderer (the title runs through our host device, which is ordinary D3D12; this has not been tried). - The licence terms of the SDKs and headers named above. - AMD Anti-Lag 2 and Intel equivalents (mentioned only as possible follow-ups; nothing was checked). ## Next step Phase 0 is a small spike and can be a PR of tests only. A PR will follow if the spike works; phases 1 and 2 wait for the decision on Streamline vs NvAPI.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:49:50 +00:00
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 05:48 UTC · original

Sibling issues opened together: #727 (settings/menu), #728 (frame pacing and latency), #729 (Reflex), #730 (upscaling), #731 (frame generation). Overlaps are named in each body; this set should stay split by subject.

**@⁠Revens2** on GitHub · 2026-11-25 05:48 UTC · [original](https://github.com/fxceless/victory-fork/issues/729#issuecomment-7154160358) Sibling issues opened together: #727 (settings/menu), #728 (frame pacing and latency), #729 (Reflex), #730 (upscaling), #731 (frame generation). Overlaps are named in each body; this set should stay split by subject.
This discussion has been locked. Commenting is limited to contributors.
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/fxceless--victory-fork#729
No description provided.