leonida-gpu: a frame limit Reflex refused is given again at the next present (D3D12-FG-REFLEX-LIMIT-RETRY) #3389

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "fg-reflex-retry:pastel-fg-reflex-retry"
git switch "pastel-fg-reflex-retry"
Open
leonida/mandy
pastel wants to merge 1 commit from pastel/mandy:fg-reflex-retry into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fg-reflex-retry:pastel-fg-reflex-retry'
git switch 'pastel-fg-reflex-retry'
First-time contributor

Claimed in the coordination issue as: D3D12-FG-REFLEX-LIMIT-RETRY (claim comment on #3312)

Depends on: #3387 (same file, d3d12/crates/leonida-gpu/src/fg.rs; the two merge together without conflict in either order)

What and why

With LEONIDA_FG_LIMIT_FPS unset or auto, the followed frame limit was given to Reflex only when it or the frames shown per rendered one moved. A limit Reflex refused (a non-ok result) stayed refused until the next window changed it. Reported by merzleckeier on the GitHub PR ProjectLeonida/mandy#3278.

Reflex's limit now keeps what it last took and what was last asked (ReflexLimit): a change it refused is due again at the next mapped present, and a refusal is logged once per value. Unmapped presents while generating still send nothing, and turning frame generation off still takes the limit off Reflex.

This is the old GitHub branch ported to this repository's main, whose present_start has changed since (mapped presents, sent_shown): ReflexLimit replaces Follow::sent_shown.

Known trade-off (from the review): if Reflex refuses every limit, reflex_set_options is called on each mapped present until it takes one. The log stays at one line per refused value.

Tested

  • cargo test -p leonida-gpu --locked (from d3d12/): 730 passed, 0 failed; the new reflex_limit_tests covers the retry, the single refusal log, the retried off and the no-limit case.
  • cargo clippy -p leonida-gpu --locked --all-targets -- -D warnings: clean.
  • python -I scripts/check_no_game_data.py on the changed file: clean.
  • Red/green: the new test does not build on main (ReflexLimit does not exist there).
  • No in-game run yet.

GPUs tested: n/a (unit tests only)

AI-assisted: yes, Claude Opus 5.5 for the code and for the separate read-only reviewer agent (verdict: ready, no bugs found).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

Claimed in the coordination issue as: D3D12-FG-REFLEX-LIMIT-RETRY (claim comment on #3312) Depends on: #3387 (same file, `d3d12/crates/leonida-gpu/src/fg.rs`; the two merge together without conflict in either order) ### What and why With `LEONIDA_FG_LIMIT_FPS` unset or `auto`, the followed frame limit was given to Reflex only when it or the frames shown per rendered one moved. A limit Reflex refused (a non-ok result) stayed refused until the next window changed it. Reported by merzleckeier on the GitHub PR ProjectLeonida/mandy#3278. Reflex's limit now keeps what it last took and what was last asked (`ReflexLimit`): a change it refused is due again at the next mapped present, and a refusal is logged once per value. Unmapped presents while generating still send nothing, and turning frame generation off still takes the limit off Reflex. This is the old GitHub branch ported to this repository's main, whose `present_start` has changed since (mapped presents, `sent_shown`): `ReflexLimit` replaces `Follow::sent_shown`. Known trade-off (from the review): if Reflex refuses every limit, `reflex_set_options` is called on each mapped present until it takes one. The log stays at one line per refused value. ### Tested - `cargo test -p leonida-gpu --locked` (from `d3d12/`): 730 passed, 0 failed; the new `reflex_limit_tests` covers the retry, the single refusal log, the retried off and the no-limit case. - `cargo clippy -p leonida-gpu --locked --all-targets -- -D warnings`: clean. - `python -I scripts/check_no_game_data.py` on the changed file: clean. - Red/green: the new test does not build on main (`ReflexLimit` does not exist there). - No in-game run yet. GPUs tested: n/a (unit tests only) AI-assisted: yes, Claude Opus 5.5 for the code and for the separate read-only reviewer agent (verdict: ready, no bugs found). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The followed limit was given to Reflex only when it or the frames shown per rendered one moved, so a limit Reflex
refused stayed refused until the next window changed it. Reflex's limit now keeps what it last took and what was
last asked: a change it refused is due again at the next mapped present, and a refusal is logged once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First-time contributor

Verified natively on Windows 11 (MSVC, no game files): python -I scripts/red_green.py against main (0043b8d33, PR head d401fce3d) — clean merge, 789/789 leonida-gpu tests passed on green (red not constructible: PR changes no tests). AI-assisted: Gemini 4 Neon (Antigravity).

Verified natively on Windows 11 (MSVC, no game files): `python -I scripts/red_green.py` against `main` (`0043b8d33`, PR head `d401fce3d`) — clean merge, **789/789** `leonida-gpu` tests passed on green (`red not constructible`: PR changes no tests). AI-assisted: Gemini 4 Neon (Antigravity).
Author
First-time contributor

In-game test (RTX 5060 8 GB, driver 621.01, Windows 11; diag build with DLSS; -SeriesS -FrameGen 2 -Resolution 540, LEONIDA_FG_LIMIT_FPS=auto):

  • The followed limit is given to Reflex as before: 18 changes in the first minute in the world, all sl::Result::eOk. It moves when the window's rate or the frames shown per rendered one change (on this card frame generation goes on and off with eWarnOutOfVRAM).
  • No call per present and no log line per present in steady state. No panic.
  • Not exercised: Reflex never refused a limit in this run, so the retry itself is covered by the unit test only.
In-game test (RTX 5060 8 GB, driver 621.01, Windows 11; diag build with DLSS; `-SeriesS -FrameGen 2 -Resolution 540`, `LEONIDA_FG_LIMIT_FPS=auto`): - The followed limit is given to Reflex as before: 18 changes in the first minute in the world, all `sl::Result::eOk`. It moves when the window's rate or the frames shown per rendered one change (on this card frame generation goes on and off with `eWarnOutOfVRAM`). - No call per present and no log line per present in steady state. No panic. - **Not exercised:** Reflex never refused a limit in this run, so the retry itself is covered by the unit test only.
Collaborator

Gate run on an RTX 3090 (NVIDIA 621.40, Windows 11 Pro build 26300) for #3387 and #3389 together: #3387 head 4f0e947ef merged into main 04a838fc4, then #3389 head d401fce3d on top (both current heads, no conflict), diag profile with diagnostics,dlss,mimalloc, msvc target. Reference: main 04a838fc4 built the same way. Series X output 2560x1440, DLSS quality, DLSS frame generation on (the 3090 runs it through a frame-generation unlocker), frame limit in auto mode, 300 s standing at the save, fresh data.

  • 0 device lost, 0 crash, 0 ERROR lines. Frame generation active from 72 s, one generated frame per rendered frame on both sides.
  • Rendered 26.6 frames/s over 150-300 s against 26.7 for main (-0.2); generated 28.0 against 28.6 per second.
  • The followed frame limit climbs back the same way as on main after reaching the world (about 18 to 29 rendered frames/s on both), mean 26.5 against 27.8.
  • Not shown by this run: whether the cases these two PRs target (a stall before any best, a limit Reflex refuses) happened in it. Nothing in the run counts them.

Indicative, one run each: p99 61.7 against 56.2 ms (+5.5 ms), and the climb from about 20 to 29 frames/s is a little slower; process CPU time per frame is higher too. A frame-timing capture tool was recording during this run and not during the reference, and other processes differ by 4.7 points of CPU, so take these as something to watch, not as a measured cost.

Verdict: PASS (no loss, frame rate within tolerance).

GPUs tested: NVIDIA GeForce RTX 3090, driver 621.40.
AI-assisted: run and report by Claude Code (Claude Opus 5.5).

Gate run on an RTX 3090 (NVIDIA 621.40, Windows 11 Pro build 26300) for #3387 and #3389 together: #3387 head `4f0e947ef` merged into `main` `04a838fc4`, then #3389 head `d401fce3d` on top (both current heads, no conflict), diag profile with `diagnostics,dlss,mimalloc`, msvc target. Reference: `main` `04a838fc4` built the same way. Series X output 2560x1440, DLSS quality, DLSS frame generation on (the 3090 runs it through a frame-generation unlocker), frame limit in auto mode, 300 s standing at the save, fresh data. - 0 device lost, 0 crash, 0 ERROR lines. Frame generation active from 72 s, one generated frame per rendered frame on both sides. - Rendered 26.6 frames/s over 150-300 s against 26.7 for `main` (-0.2); generated 28.0 against 28.6 per second. - The followed frame limit climbs back the same way as on `main` after reaching the world (about 18 to 29 rendered frames/s on both), mean 26.5 against 27.8. - Not shown by this run: whether the cases these two PRs target (a stall before any best, a limit Reflex refuses) happened in it. Nothing in the run counts them. Indicative, one run each: p99 61.7 against 56.2 ms (+5.5 ms), and the climb from about 20 to 29 frames/s is a little slower; process CPU time per frame is higher too. A frame-timing capture tool was recording during this run and not during the reference, and other processes differ by 4.7 points of CPU, so take these as something to watch, not as a measured cost. Verdict: PASS (no loss, frame rate within tolerance). GPUs tested: NVIDIA GeForce RTX 3090, driver 621.40. AI-assisted: run and report by Claude Code (Claude Opus 5.5).
pastel force-pushed fg-reflex-retry from d401fce3db to 6dc54a306c 2026-12-04 12:19:53 +00:00 Compare
pastel force-pushed fg-reflex-retry from 6dc54a306c to b9c23d9b67 2026-12-04 14:03:28 +00:00 Compare
Collaborator

The retry is right: a refused frameLimitUs is due again at the next present, and the ReflexLimit tests pin the retry and the told-once behaviour. It conflicts with #3458, which replaces SHOWN with the debounced mutex in the same function; rebase after #3458 (already gate-tested) and keep shown_now() in the due call.

The retry is right: a refused `frameLimitUs` is due again at the next present, and the `ReflexLimit` tests pin the retry and the told-once behaviour. It conflicts with #3458, which replaces `SHOWN` with the debounced mutex in the same function; rebase after #3458 (already gate-tested) and keep `shown_now()` in the `due` call.
pastel force-pushed fg-reflex-retry from b9c23d9b67 to 6f8d088ed9 2026-12-04 15:13:49 +00:00 Compare
Author
First-time contributor

@vayko thank you for the review. Understood on #3458: once it lands I'll rebase this onto it and keep shown_now() in the due call, then rerun the ReflexLimit tests. Head is now 6f8d088ed9, rebased on main ebbb84048c with no code change (cargo test -p leonida-gpu --locked: 759 passed; clean-room check passes).

AI-assisted: yes

@vayko thank you for the review. Understood on #3458: once it lands I'll rebase this onto it and keep `shown_now()` in the `due` call, then rerun the `ReflexLimit` tests. Head is now `6f8d088ed9`, rebased on `main` `ebbb84048c` with no code change (`cargo test -p leonida-gpu --locked`: 759 passed; clean-room check passes). AI-assisted: yes
pastel force-pushed fg-reflex-retry from 6f8d088ed9 to 8b185e02b5 2026-12-04 16:12:40 +00:00 Compare
pastel force-pushed fg-reflex-retry from 8b185e02b5 to f8ce2f1c44 2026-12-05 06:11:21 +00:00 Compare
Sign in to join this conversation.
No description provided.