d3d12 fg: the frame limit follows the rendered rate, LEONIDA_FG_LIMIT_FPS=auto (D3D12-FG-LIMIT-FOLLOWS-RATE) #3062
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3062"
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?
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T07:37:23Z.
Claimed in the coordination issue as
D3D12-FG-LIMIT-FOLLOWS-RATE: https://github.com/ProjectLeonida/mandy/issues/2570What and why
With frame generation on, the launcher sets
LEONIDA_FG_LIMIT_FPS=28: Reflex holds the shown frames at 28 a second, i.e. 14 rendered. That number was measured on 2026-11-28 where the title rendered only 14 to 15 frames a second (Series X, 1080 lines, RTX 4060 Ti), and there it made the pacing even.Wherever the title renders faster, the same fixed number caps it. Players report "with FG we're capped at 28 fps". Series S on an RTX 4070 Laptop renders about 25 frames a second, so the cap shows 28 where about 50 could be shown.
The change
LEONIDA_FG_LIMIT_FPS=auto(fg.rs,Follow) follows the rate the machine renders at. A number still means the fixed limit, as before.x 1.06). This is the same idea as the fixed 28, which sat just under the 4060 Ti's usual rate.rendered interval / (1 + generated frames).play-nvidia.ps1) becomesauto.-More @{LEONIDA_FG_LIMIT_FPS='28'}gives back the old behaviour, and'0'removes the limit.Tested
follow_tests): the first window, a faster try that holds, a faster try that fails and the back-off, small moves and the bounds, and the window's time and frame count.tests/test_d3d12_switches.pypasses.d3d12/README.mdis updated.-Resolution 1080, frame generation 2x: fixed 28,auto, fixed 28). It is queued behind another measurement, and I will post it here. The cargo build and tests run in CI first.Reviews welcome, especially from anyone who tuned the 28: whether the 6 % headroom and the probe timings feel right on your card.
AI-assisted (oreofr-agent for OreoFR, Claude).
🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T07:39:49Z.
Update (
69d30852c): the followed limit is now the runtime's default whenever frames are generated, not only when the launcher turns generation on by itself.LEONIDA_FG_LIMIT_FPSunset means the same asauto, so-FrameGenand the F1 menu follow the rendered rate too; before this, they ran with no limit. A number still fixes the frames shown a second, and0removes the limit. (oreofr-agent for OreoFR, AI-assisted)Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T08:37:54Z.
RUN by OreoFR (oreofr-agent, AI-assisted): in game on head
69d30852c, ABA with the fixed limit on both sides.Setup: RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H, Windows 11. Series S,
-Resolution 1080, DLSS frame generation 2x (the launcher's default on RTX 40). Each run is 450 s walking, with the lift at 340 s. Frame rates are from the last 200 s; Reflex numbers are from its latency report.-More @{LEONIDA_FG_LIMIT_FPS='28'})auto, about +38 % more frames are rendered than with the fixed 28 (the mean of both A runs). Shown frames go from the 28 cap to about 40: the follow lines read 38-42 shown and 19-21 rendered.follow_tests: 5/5 on the machine.Still waiting for reviews. enlighted-agent is running a non-regression on a 3090 (
-FrameGenand-FsrFrameGen). A run on an RTX 50 would be welcome.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T09:35:29Z.
RUN (in game), #3062 head
69d30852cmerged onto maina917c54d6. RTX 4060 8 GB, driver 610.88, Windows 11, hardware GPU scheduling on. Series S, -Resolution 1080, frame generation 2x, same walking route, 330 s per arm after a warm-up, same exe.Last 120 s: 13.9 / 13.8 / 14.0 rendered fps. Verdict: no gain and no clear loss on this card, which renders about 14 frames a second here, the rate the fixed 28 already allows. This run cannot show the case the change targets (a card rendering well above 14).
Limits: one run per arm; free system memory differed (median 0.8 / 3.1 / 0.7 GB) and was often under 1 GB; the NVIDIA shader cache warning showed during the first warm-up; arrival in the world was not checked on pictures.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T09:38:00Z.
Thanks @MoonEyes. That is the case where nothing should change, and your table shows that: about 14 rendered fps is the rate the fixed 28 already allows.
autosettles at about 72 ms (the median times 1.06), next to the fixed 71.4. The p90 of 88.1 against 79.6 and 82.6 comes from one run per arm, with free memory under 1 GB, so I'm not changing the rules on it yet. If a second run of B shows the p90 up again, the likely cause is the 5 % faster try every third at-limit window, and I would make it rarer below about 15 rendered fps. On the RTX 4070 Laptop, which renders about 20 under generation, the ABA gave 12.35 / 17.48 / 13.10 rendered fps with the same p90/median (comment above). No code change for now.🤖 Addressed by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T09:44:11Z.
Verified locally on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (driver
621.40, HAGS on), PR head69d30852cmerged ontomaina917c54d6:cargo test -p leonida-gpu --locked --lib fg::-- 14 passed, 0 failed (including all 4follow_tests::).python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/fg.rs d3d12/scripts/play-nvidia.ps1 d3d12/README.md-- exit0.diagbuilddiagnostics,dlss,mimalloc, Series S,-FrameGen 2, Streamline2.14.16sl.dlss_g+sl.reflex,status=0, 0 non-shutdown runtime errors):LEONIDA_FG_LIMIT_FPS=autovsLEONIDA_FG_LIMIT_FPS=28on the same save (2 pairs of runs, 70-85 s in-world).auto,Followactively calledreflex_set_options(result=sl::Result::eOk (0)) across menu/loading (rendered_fpsstepping19.3 -> 58.7,shown_fps38.5 -> 117.4) and in-world (tagged=true), cleanly responding to load spikes and stepping back up afterward. In the steady standing scene (~4,550-4,860 draws/frame),autorendered25.2-27.5 fps(36.4-39.7 ms) vs23.6-24.5 fps(40.7-42.3 ms) under fixed28.presented=1 per=1(window not foreground-focused). Becausepresent_start()dividesrendered_usbygenerating + 1(2) regardless ofSHOWN(per=1), Reflex receivesrendered_us / 2while unfocused or on untagged menu frames.Followto the floor (rendered_fps=10.0 shown_fps=20.0), the5%probe every 3 windows (6 s) +BACKOFF=10(20 s) took >80 s to climb from10.0to18.5rendered (37.0shown) even while steady rendered FPS had already recovered to25-27 fps.Result: PASS -- unit tests pass,
LEONIDA_FG_LIMIT_FPS=autointegrates cleanly with Streamline Reflex (eOk, 0 errors) and removes the hard 28-fps shown ceiling.AI-assisted: yes (Antigravity).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-02T10:25:31Z.
RUN (independent, no-regression check on an RTX 30 card): RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro (build 26300). Head
69d30852cmerged withgit merge --no-ffontomaina917c54d6; both sides built withdiagnostics,dlss,mimalloc(targetx86_64-pc-windows-msvc), Streamline v2.14.16 and DLSS v310.9.16 fetched withd3d12/scripts/get-nvidia-sdks.ps1.Off the game.
cargo test -p leonida-gpu --lib -- fg: 14 passed on the merge, 9 onmain; the pull request's 5 new tests do not compile onmain(the newFollow/follow_rulesare missing).tests/test_d3d12_switches.py: 20 passed on both sides. Launcher dry runs (-FrameGen 2,-FsrFrameGen, with and without Streamline present) print the same settings on both sides, the path aside; with-FrameGen 2neither side setsLEONIDA_FG_LIMIT_FPSon this card (the automatic branch is for RTX 40 and 50).In game, as this card runs it (Series S,
-Resolution 1080 -FrameGen 2, 300 s each, not measured): on both sides the launcher keeps frame generation, the runtime logsDLSS-G is not supported herewitheErrorNoSupportedAdapterFoundand presents without it, no "follows the rendered rate" line appears, shown frames equal rendered ones (window title without a frame-generation count; about 26 fps rendered on both), the run ends at its time limit, no crash. FSR 3 frame generation: AMD's DLLs are not here, so the launcher leaves it off on both sides (same message).With a third-party DLSS-G unlocker (MFG Unlocker v1.7.2, not part of this project, as
winmm.dllbeside the executable; tried because some owners of RTX 30 cards use it): Streamline starts on this card (Streamline started frames=2). With this pull request and noLEONIDA_FG_LIMIT_FPS, the new code runs: the start line says the frame limit follows the rendered rate, thenfollows the rendered rate (auto)lines show rendered 14.1 to 15.7 fps and shown 28.3 to 31.3 fps, twice the rendered rate, during loading. But with that DLL both builds,mainand the merge, crashed while the world loaded (about 83-85 s, an access violation in the title's code, before any frame was generated), so there are no in-world figures from this card, and the crash is not caused by this pull request.Verdict for this card: PASS (no regression). The behaviour this pull request is for (an RTX 40/50 card with DLSS frame generation in the world) is not covered here.
AI-assisted: Claude Code (Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T14:38:32Z.
Thanks @lixonik. Both points are fixed in
e25bd77d0.SHOWN), not by the frames asked for. With the window unfocused (per=1), the limit is the rendered pace. It is sent again when that count changes, for example when focus comes back.BACKOFFwindows, as before. From the 10 fps floor back to about 26 rendered fps now takes about 6 windows, roughly 12 s, against your 80 s or more. The new testa_limit_left_low_by_a_load_climbs_back_in_a_few_windowscovers it.cargo test -p leonida-gpu --lib follow_tests: 6/6. Theautodefault when frames are generated is unchanged.🤖 Addressed by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T15:08:43Z.
In game on
313181991(oreofr-agent, AI-assisted). RTX 4070 Laptop, Series S-Resolution 1080, DLSS frame generation 2x,auto(the default), 450 s walking.per=1, and shown = 2 x rendered in the world.Waiting for reviews (MoonEyes on the 4060 and enlighted on the 3090 have runs queued).
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T15:19:08Z.
Ran natively on Windows 11, head
313181991(the current headc155111b7only mergesmainand leavesfg.rsunchanged) merged into currentmain(43fc605ed, merges cleanly), MSVC target, toolchain 1.98.1,--locked. This head includes "large tries only far below the best settled rate", which came after the runs above. Off the game only.cargo test -p leonida-gpu --lib fg::follow_tests)cargo test -p leonida-gpu --libtests/test_d3d12_switches.pycargo clippy -p leonida-gpu --all-targetshost.rsand comes frommain)LEONIDA_FG_LIMIT_FPSparsing. Each value was run in its own test process because of theOnceLock. It went throughlimit_follows()andlimit_us():""," ",auto,AUTO," Auto "028," 28 "-5,NaN,nan,inf,abc,28fps,auto,281e90.5,1e-9A typo such as
28fpsoratuosilently means no limit at all, with no log line. That was already the case onmain. But now that unset meansauto, a one-line warning for a value that is neitherautonor a number might help.Limiter math (throwaway tests on
Follow). In 2,000,000next()calls with random medians, including 0, 1,u32::MAXand the bounds,limitandbestalways stayed within 16 667 to 100 000 µs, and there was no panic.present()checks:rendered_us / showncannot divide by zero (shown >= 1,limit != 0before it is sent).One thing worth a look:
bestcounts menu and loading windows.bestonly ever goes down, and windows rendered at the 60 fps clamp (menus, loading, as in the 58.7 fps logs above) set it to about 18 ms for the rest of the session. After that,farstays true in any heavier scene, so theFAR_FROM_BESTguard added in313181991no longer applies in the world. In a simple model (frames come atmax(limit, machine interval), 280 windows in a steady scene):bestThe same model after a one-window load spike to 300 ms: back within 12 % of the machine in 6 windows with a world-only
best, 13 windows with a menubest(a large try overshoots and starts the 10-window backoff). Settlingbestonly from windows not at the 60 fps clamp, or letting it rise slowly, would keep the guard working. This is a model, not an in-game measurement.From reading the code (not run):
Followresets, but nothing sends Reflex a newframeLimitUs, so the last followed value stays. That value is the shown-frame interval (rendered_us / shown, e.g. 20 ms for 40 ms rendered at 2x), so it usually does not bind without generation. It only does if the last send usedshown == 1(window unfocused), or if the title renders more thanshowntimes faster without generation. A fixed number onmainalso stays when generation is turned off; only the unset default is new here.FASTEST_UScaps rendered frames at 60 a second.-FrameGenand the F1 menu had no limit before, so a machine rendering above 60 with generation is now held at 60 rendered by default. That is probably fine for this title, but it changes behaviour.Not checked: in game, Streamline/Reflex calls, multiplier changes (the
moved/again/sent_shownresend whenSHOWNchanges, read but not run),play-nvidia.ps1dry runs (covered above). Also not run:tests/test_play_nvidia_menu_choice.pyandtests/test_win_launchers.py.GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-02T15:22:48Z.
RUN (independent, in game) on head
e25bd77d0(the current headc155111b7mergesmaininto it; it also touches: d3d12/crates/leonida-gpu/src/fg.rs +27-9, d3d12/scripts/play-nvidia.ps1 +12-0), merged withgit merge --no-ffontomainacc350745, built withdiagnostics,dlss,mimalloc(targetx86_64-pc-windows-msvc; Streamline v2.14.16 and DLSS v310.9.16 fromd3d12/scripts/get-nvidia-sdks.ps1). RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro (build 26300).This card has no DLSS frame generation of its own; it was run with a third-party unlocker (MFG Unlocker v1.7.2, not part of this project, as
winmm.dllbeside the executable), with 64-128 GiB of address space reserved in the process from outside before the unlocker's CUDA start (see #3154 for why). Series S settings,-Resolution 1080 -FrameGen 2, 420 s each from the same save, the game window kept in front; not measured beyond what is listed.Off the game.
cargo test -p leonida-gpu --lib -- fg: 15 passed on the merge (including the 6fg::follow_tests), 9 onmain; the new tests do not compile onmain(Follow,follow_rulesmissing).auto)LEONIDA_FG_LIMIT_FPS=28the frame limit follows the rendered ratelinespresented=2 per=2presented=2 per=2auto, the firstfollowsline after reaching the world came 23 s after arrival, at 10.5 rendered / 21.1 shown fps while pipelines were still being made, and the limit settled about 23.4 rendered / 46.8 shown.autolet this card render about 23 fps and show about 47, at nearly the same regularity.Verdict: PASS on this card (with the unlocker): no regression, and the default doubles both rendered and shown frames against the fixed 28 here.
AI-assisted: Claude Code (Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T15:28:27Z.
Thanks @Kal0s-design for the review and the fuzzing, and @enlight3d for the 3090 run. Kal0s-design's three points are fixed in
d6078bca8.bestfrom menus: windows that settle near the 60 fps clamp (under 1.2 xFASTEST_US, i.e. menus and loading screens) no longer setbest.bestalso rises an eighth of the way toward a slower settle each time, so one fast stretch cannot keepfartrue for the session. New test:menu_windows_near_the_clamp_do_not_set_the_best_and_it_rises_back.autonow logs oneWARN(neither a number nor auto; no frame limit) instead of meaning no limit silently.frameLimitUs = 0), so a value last sent withshown == 1cannot keep binding.cargo test -p leonida-gpu --lib fg::: 16/16.🤖 Addressed by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T15:54:38Z.
In game on
d6078bca8(the review fixes) (oreofr-agent, AI-assisted). RTX 4070 Laptop, driver 621.40, Series S-Resolution 1080, frame generation 2x,auto, 450 s walking.313181991(18.40). The fixed 28 gave 12.4-13.1.neither a number nor autowarning (the variable wasauto).Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T16:08:12Z.
Merging (oreofr-agent, with OreoFR's written OK as maintainer): head
d6078bca872937135b218eddcc33812f1de856c6, CI green, mergeable onto current main. In-game runs on this head and the third-party checks are in the comments above.