leonida-gpu: debounce the frame-generation shown count, so one bad poll cannot latch 5 fps (#3260) #3458
Code
Clone this repository
Checkout
From your project repository, check out a new branch and test the changes.
git fetch -u"d3d12/fg-shown-debounce:KelboLive-d3d12/fg-shown-debounce" git switch "KelboLive-d3d12/fg-shown-debounce"
Open
leonida/mandy
KelboLive
wants to merge 2 commits from
KelboLive/mandy:d3d12/fg-shown-debounce into main
pull from: KelboLive/mandy:d3d12/fg-shown-debounce
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3458
Loading…
Reference in a new issue
No description provided.
Delete branch "KelboLive/mandy:d3d12/fg-shown-debounce"
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?
This pull request can be merged automatically.
Reviewers 0 approvals
Details
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.What/why
#3260: the frame rate can lock to exactly 5.0 fps after a few minutes. The audit found it is the FG auto-limiter's shown-frame divisor, not load:
dlssg_get_statepoll withper != 1forcedshown = 1(oldfg.rspoll path);present_startthen sentframeLimitUs = rendered_us / shownwhile DLSS-G still showed 2, so Reflex paced two shown frames;SLOWEST_US = 100_000that is 200 ms = 5.0 fps, and it self-sustains because every later poll agrees with the locked state.The attached log fits arithmetically: sent 86,207 us -> measured 172.2 ms (2x), sent 100,000 us -> measured 200.0 ms (2x).
Change
Debounce the adopted shown count instead of changing the arithmetic:
Shown { current, candidate, votes }withpolled(per); a differing poll only becomes a candidate, and the value is adopted on the second consecutive agreeing poll;peris clamped to1..=6, raw0treated as1; a poll equal tocurrentclears the candidate;reset_shown()restores 1 immediately when generation is turned off;present_endfeeds every poll (including the forced1on failure),present_startand the HUD read the adopted value; therendered_us / shownarithmetic and theagainsend path are unchanged;shownand whether the poll was adopted.A real generation stop is sustained, so it is still followed after ~20 presents (~1.5 s at 13 fps); a one-frame hitch can no longer double the limit.
Behaviour
2,1,2-> stays 2;2,1,1-> 1;1,2,2-> 2;2,2,1,2,2-> never changes; sustained 1 -> changes once.Tests
cargo test -p leonida-gpu --lib fg::: 26 passed; full serial: 760 passed, 0 failed, 60 ignored.2,1,2, alternating, sustained-first-sample, zero); green with the debounce.Interaction
Follow's slow window; no semantic overlap.ReflexLimit::due(...), which still divides byshown; expect a textual overlap inpresent_start, resolved by feedingshown_now()intodue(...)and keeping the retry. Complementary: debouncing stops a flapping count from producing spurious limit changes.Not done
No game run. The one-run falsification from the issue still applies before merge: same save/settings with
LEONIDA_FG_LIMIT_FPS=0should remove the 200.0 ms flatline if this is the cause, and with this branch the flatline should not appear at all. A run with FG on and the fix is needed to confirm the latch is gone.Item: D3D12-FG-SHOWN-DIVISOR-DEBOUNCE, claimed in #3312. Depends on: none.
AI-assisted: DeepSeek V4.1 Flash (OpenCode); the diagnosis and the state machine were reviewed separately.
Read the diff and the surrounding
present_start/present_end. The state machine is total, the tests cover the alternating and sustained cases, and the lock order is the same in both paths (statethenSHOWN), so no deadlock;shown_per_frame()is called once per frame (host.rs:13965,menu.rs:151,panel.rs:167), not per draw item.Two questions before this goes in:
currentstarts at 1 and adopts 2 only on the second agreeing poll, i.e. 10-20 presents after generation turns on. In that windowpresent_startdividesrendered_usby 1 while two frames are shown, so a 60 fps cap briefly aims at 60 rendered / 120 shown (about 0.3 s at 60 Hz). Is that trade-off intended, against adopting on the first poll?One nit:
shown_per_frame()now takes the mutex on every call where it was a relaxed load. That is once per frame today, but a comment on the trade-off would keep the next reader from "optimising" it back.The logic itself looks right to me.
Ran the gate on this branch (head
e581ff2b2) with the game:diagbuilddiagnostics,dlss,mimalloc, RTX 5070, driver 32.0.16.2101, 1440p, default play switches (frame generation on,LEONIDA_FG_LIMIT_FPS=auto).PASS: 302.7 s in the world, no device loss, no panic, exit 0 (clean), median 20.6 fps, p5 11.9, longest present gap 1.64 s, cache saved.
The debounce does what it says in the log:
index=6000/6600/7200: status 0, presented 2, per 2, shown 2;index=7800: presented 1, per 1, shown still 2,adopted=false— the first poll alone does not move the count;index=8400: shown 1.The followed limit follows it:
rendered_fps=22.8 shown_fps=45.7while generation worked,11.9/11.9after it stopped.One detail from the run: generation dropped from 2 to 1 around
index=7800withstatus=0still, so it was not a failing poll but Streamline genuinely presenting one frame (the gate's window is not focused, which is the case the comment inpresent_endalready names). That is exactly the flapping this debounce has to absorb, and it did.My question 2 stays open in the only sense that matters: 2 votes versus 3 would need an A/B build. If you want that number, say how many votes and I will run both back to back on this machine and post the two summaries.
354c8fc0d3toc035e97e3dRebased onto
main44c480a5f(headc035e97e3). No conflicts. Re-ran: 769 passed, 0 failed, 60 ignored. The one known conflict with #3389 is still the singlefg.rshunk; this branch is unchanged in that area.Thanks for the read and the run.
1. The startup transient is intended. The harmful direction is only the fall: 2 shown / divisor 1 is the #3260
200 msframe (the 100 ms floor divided by one). The rise from 1 to 2 while two frames are actually shown just means the cap aims at the refresh for ~10-20 presents instead of half of it - it cannot produce a long frame. Adopting the first poll would reintroduce exactly the case your run caught atindex=7800: one poll saying 1 while Streamline is not generating, and a 200 ms frame on every flap. So: a benign 0.3 s under-limit at startup for no 200 ms hitches is the trade.2. Two votes, not three. The poll cadence is one per present, and the failure case is a single stale reading. Two agreeing polls is the smallest number that rejects one stale poll while keeping the fall inside two presents; a third vote would add another present dividing by 1 while two frames are shown - the direction we can least afford. That is a code-derived choice, not a measured optimum, so if your A/B shows a sustained 1 exposed for more than two polls (not a one-poll flap), that is the evidence that would make it 3, and I would take it. Otherwise I would not spend a run on it.
The nit is fair -
shown_per_frame()is once per frame today and the lock is uncontended. I will add the comment so nobody "optimises" it back to a relaxed load that cannot carry the two fields.c035e97e3dtoaa0f5c7f05Replayed onto
mainbba262b94(headaa0f5c7f0). No conflicts. Re-ran: 788 passed, 0 failed, 60 ignored.aa0f5c7f05toa6d90ba397Replayed onto
maine1be896b2(heada6d90ba39). No conflicts. 788 passed, 0 failed, 60 ignored.a6d90ba397to4087afa09aReplayed onto
main00e245be5(head4087afa09). No conflicts. 798 passed, 0 failed, 60 ignored.4087afa09ato076714f11aReplayed onto
mainf22b9fa64(head076714f11). No conflicts. 801 passed, 0 failed, 60 ignored.076714f11atodfe69d85e4Replayed onto
main6491bc1a1(headdfe69d85e). No conflicts. 801 passed, 0 failed, 60 ignored.dfe69d85e4to8f9d3f609bReplayed onto
main6b0498d37(head8f9d3f609). No conflicts. 801 passed, 0 failed, 60 ignored.RUN —
8f9d3f609(rebased onmain6b0498d37),NVIDIA RTX 5070 12 GB,Windows 11.Static & unit checks
cargo test -p leonida-gpu --lib --locked fg:::32/32PASS (0failed)cargo clippy -p leonida-gpu --all-targets --locked -- -D warnings:0warnings infg.rs(only pre-existing Rust deprecation lints in untouched files)python -I scripts/check_no_game_data.py: PASSLive 335 s run with DLSS Frame Gen (
-SeriesS -FrameGen 2 -NoPrecompile -AutoMenu)38samples with>= 1000draws,180 sin world,max_draws = 5,483):3000-4999draws (31samples) median21.8 fps(23.7-25.0 fpssteady-state in the final 40 s after the auto-limiter finished climbing from the initial10.0 fpsworld-entry stall; overall world median18.2 fps,54.9 ms).0ERRORlines prior to clean window close,device-lost.txt = false, peak video memory8,373 / 10,941 MB.leonida_gpu::fgtelemetry:sl.dlss_ginitialized cleanly (frames=2,max=5,status=0,tagged=trueon world entry,result=sl::Result::eOk (0)).statefields (per,shown,adopted) logged cleanly on every poll interval, and the auto-limiter never latched to5.0 fps(steady-stateLEONIDA_FG_LIMIT_FPS=autosettled at23.7-26.8 fps).presented=1, per=1, shown=1, adopted=falsethroughout (so the live run verified the Streamline/Reflex/polling integration and steady-state path, while the2 -> 1fall-debounce and immediate-rise transitions are verified by the32/32unit tests).AI-assisted.
8f9d3f609btof278abcae7Replayed onto
main0036195a7(headf278abcae). No conflicts. 801 passed, 0 failed, 60 ignored.f278abcae7to7f4c458338Replayed onto
mainf4b0404e9(head7f4c45833). No conflicts. 801 passed, 0 failed, 60 ignored.7f4c458338to0ae4a1ae80Replayed onto
main93b9d90a2(head0ae4a1ae8). No conflicts. 801 passed, 0 failed, 60 ignored.0ae4a1ae80to317ba51bf3Replayed onto
mainc5355dd25(head317ba51bf). No conflicts. 802 passed, 0 failed, 60 ignored.317ba51bf3to4bf57e1532Replayed onto
maine1b0248c1(head4bf57e153). No conflicts. 802 passed, 0 failed, 60 ignored.4bf57e1532to2a23246f00Replayed onto
maind99bb4d7a(head2a23246f0), which adds #3295's frame-generation-limit test in the samefg.rs. No conflict; 805 passed, 0 failed, 60 ignored.