d3d12-gpu: keep DLSS-G off until first upscale or G-buffer inputs arrive #3216
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3216"
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 lixonik on 2026-12-02T19:55:08Z.
Claimed in the coordination issue as:
D3D12-FG-DEFER-ENABLE-UNTIL-INPUTS(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7356493093)Addresses #3137 and #3186 (removes the menu/loading Streamline warning burst; does not close #3186).
What and why
d3d12/crates/leonida-gpu/src/fg.rspreviously calleddlssg_set_options(DLSSGMode::eOn)on present 1, before any upscale or G-buffer pass had populatedLATESTwith depth and motion vectors. During startup logos, menus, and loading screens (2,000-3,300 presents):dlfgPresent.cpp:2251 Warning: missing common constants - Frame Generation will be disabled for the framewarnings (3,326 in a Series X 1440p run onmain), making logs look broken or masking unrelated loading crashes (#3137, #3186).Follow(LEONIDA_FG_LIMIT_FPS=auto) andhudless_at_presentstarted running during menus before any world frame existed.This change:
EVER_TAGGED: AtomicBool(set withOrdering::Releaseoncenote_titles,tag, orgbuffer_at_presentpopulatesLATESTwith non-zerodepthandmotionhandles, read withOrdering::Acquireinpresent_start).DLSSGMode::eOff(witheRetainResourcesWhenOff) while!has_inputsvia pure helperseffective_framesandshould_poll_options, logging once that frame generation is waiting for the first upscale or G-buffer pass.dlssg_set_optionson the very first present wherehas_inputstransitionsfalse -> true(even on a non-multiple-of-8 present) beforeset_constants/set_tag_for_frame/Present, so no in-world frame is missed.fg::defer_enable_tests::{stays_off_until_first_inputs_then_clamps_to_card_max, polls_on_first_present_on_first_inputs_and_every_eighth_present}.Tested
cargo test -p leonida-gpu --features diagnostics --lib --locked fg::-- 18 passed, 0 failed (including both newdefer_enable_tests).python -I scripts/check_no_game_data.py-- PASS.41a1c8791(based onmainf1a559851, clean merge)diagprofile (diagnostics,dlss,mimalloc), Series X-Resolution 1440(LEONIDA_OUTPUT=2560x1440,LEONIDA_RENDER_SCALE=1,LEONIDA_OWN_UPSCALER=1,LEONIDA_FRAME_GEN=2,LEONIDA_FG_LIMIT_FPS=28), same restored save snapshotmissing common constantswarnings41a1c8791onf1a559851)main(69cd4106c, same Series X 1440p FG 2x profile)Observed transition in the PR run:
frame generation: waiting for the first upscale or G-buffer pass before turning on result=sl::Result::eOk (0) asked=2depth and motion vectors are the G-buffer pass's from now on size=[2560, 1440]->amount set (1 = off) result=sl::Result::eOk (0) frames=2->a present told as a reset index=3213kBufferTypeHUDLessColortagged,tagged=true status=0through present 5120+, 0missing common constants, 0constants or tags refused.GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver 595.79, Windows 10 x64)
AI-assisted: Antigravity (Gemini 4 Neon; separate read-only reviewer subagent: Antigravity Pro preset / Gemini Pro)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T20:10:02Z.
Review: COMMENTED
Source review on
41a1c8791. The startup gate currently latches when the stored depth and motion handles are both nonzero. That can precede a present with taggable inputs. The stretch fallback atlist.rs:1159–1166only needs colour and output to succeed and then passes the original depth and motion handles intotag_plain. Atfg.rs:1422–1435, either handle can still failis_resourceormade_copy. In this casepresent_starthas already armed DLSS-G and leaves it armed even though it skipsset_constantsand the tags for that present. Please defer the one-time transition until the present can resolve both host copies, and cover a first pair of nonzero handles without a host copy. This is a source review of the fallback path; I did not run Streamline or a GPU workload. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by icdmkg2 on 2026-12-02T20:22:19Z.
Third-party Windows verification of #3216 (
D3D12-FG-DEFER-ENABLE-UNTIL-INPUTS) on head41a1c879141a1c879161b7ee79b0b422cde1e28e8ff0bb93dmerged cleanly (git merge --no-ff) ontoorigin/mainb41763227.621.24(32.0.16.2124), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 1110.0.26300.9974,rustc 1.98.1.Results (MEASURED)
python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/fg.rs0python -I scripts/red_green.py 3216 --mutate764passed,0failed inleonida-gpu; red:verdict: red not constructible(see note below)LEONIDA_ADAPTER=5060cargo test -p leonida-gpu --features diagnostics --locked --lib -- fg::18 passed, 0 failed(including both newfg::defer_enable_tests::*)Review notes (READ IN CODE)
fg.rs): Keepingwant = 0(DLSSGMode::eOffwitheRetainResourcesWhenOff) while!has_inputskeepss.set == Some(0), which naturally preventsFollow(LEONIDA_FG_LIMIT_FPS=auto) andhudless_at_presentfrom running on menu/loading presents; on the first present whereEVER_TAGGEDflipstrue,should_poll_optionsrefreshes options immediately (even off the 8-present cadence) beforeset_constants/set_tag_for_frame.scripts/red_green.pyreportsred not constructiblebecause#[cfg(test)] mod defer_enable_testsis in the same contiguous hunk as the new non-test helpersshould_poll_optionsandeffective_frames(and those tests call the new helpers directly rather than testing an existing entry point). Separating the#[cfg(test)]module or adding a test exercisingtag/note_titles→EVER_TAGGEDis optional but would strengthen test coverage.Gemini; separate read-only reviewer subagent: Gemini Pro; naming the specific model tiers fromCONTRIBUTING.md(e.g., Gemini Neon/Carbon) would make AI disclosure complete.AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T20:46:29Z.
Thanks @merzleckeier and @icdmkg2 for the sharp reviews! Addressed in
1588ccebf:EVER_TAGGED, derivedClone, CopyonLatest, movedresolve_latest(is_resource+made_copyfor bothdepthandmotion) ahead ofdlssg_set_optionsinpresent_start, and gated arming ons.had_inputs || found.is_some(). A stretch fallback (tag_plain) passing nonzero handles whose host copies do not exist yet now keepsDLSSGMode::eOffuntil a present actually resolves both host copies.LEONIDA_FG_MARKERS=1presents: resolvedreflex_index(frame)ahead ofshould_poll_options,Follow, andhudless_at_presentso an unmapped present never armss.had_inputs/DLSSGMode::eOnor drops a hudless copy without constants/tags (and clearsTAGGED/LAST_FRESHso the next mapped present resets cleanly).defer_enable_testsinto its own block at the bottom offg.rsand addednonzero_handles_without_host_copies_do_not_arm_frame_generation(covering missing both copies, missing motion copy, arming once both resolve, and staying latched across a later transient miss).cargo test -p leonida-gpu --features diagnostics --lib --locked fg::-- 19 passed, 0 failed;python -I scripts/check_no_game_data.pyPASS; independent read-only reviewer subagent (Gemini Pro) -- APPROVE.RUN (in game) -- updated head
1588ccebf1588ccebf(based onmainf1a559851, clean merge)diagprofile (diagnostics,dlss,mimalloc), Series X-Resolution 1440(LEONIDA_OUTPUT=2560x1440,LEONIDA_RENDER_SCALE=1,LEONIDA_OWN_UPSCALER=1,LEONIDA_FRAME_GEN=2,LEONIDA_FG_LIMIT_FPS=28), same restored save snapshotmissing common constants1588ccebfonf1a559851)main(69cd4106c, same profile)AI-assisted: yes (Antigravity -- Gemini; separate read-only reviewer subagent: Gemini Pro).
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T20:47:40Z.
VERIFY-3216 — Windows nativo: 18 tests de
fg, control sintético, y la suite sin regresiones(this PR)f1a559851(behindmainb41763227)main—git merge --no-ffclean, no overlapRan
The one failure is this machine's, unchanged all day:
descriptor::host::tests::views_are_made_beside_the_heap_and_copied_infails identically on cleanmain(the iGPU artefact ofD3D12CreateDevice(None, ..)that #2995 addresses).The PR brings its own tests, so the red side had to be built synthetically — the new tests live in
fg.rs, so reverting the file deletes them. I copied the head, replaced the polling predicate withtrue(poll every present), rebuilt and ran:That is the exact behaviour the PR is about: it fails where a menu present would poll.
Why I think the change is right, read rather than inferred:
effective_frames(asked, most, has_inputs)returns 0 until a pass has populated depth and motion vectors, so DLSS-G is not asked to generate from menu/loading presents — which is themissing common constantswarning that #3137 and #3186 are about.EVER_TAGGEDis set in the three places that supply the inputs (upscale and G-buffer paths), and the polling predicate then only forces an immediate option refresh on the first present and on the first present with inputs, with an every-8th-present fallback for the F1 menu / A-B changes.What I could not test
mostcomes from the Streamline query, and here only the function's arithmetic is exercised.Verdict: the new tests bite, and the change is in the right place for the warning it targets; strictly it is
red not constructible(its own tests ship with it), and I say that rather than call the synthetic control a red side.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T20:53:16Z.
Review: COMMENTED
Rechecked
1588ccebon currentmain26c152ce. The missing-host-copy path from my first review is addressed. I extracted the exact policy helpers and all threedefer_enable_testsinto a CPU-only Rust harness, and all passed. One new edge case in the marker path: the return atfg.rs:1275–1279now precedes the option poll. If generation is already on and the user turns it off, a sequence of unmapped presents can leave the old DLSS-G mode and the followed pacing in effect. The previous ordering could apply the off request even without a Reflex index. Please keep enable dependent on a mapped present while allowing disable and pacing cleanup without one. I did not run Streamline or a GPU workload. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T22:07:15Z.
@merzleckeier Thanks for catching that marker-path edge case! Addressed in
055553f9a:reflex_index(frame)is still resolved before polling options, somapped = index.is_some()gates latest host-copy resolution, armings.had_inputs, enabling/changing active DLSS-G mode, advancingFollow, and enteringhudless_at_present(true, ...)/new_frame_token.effective_frames(asked, most, has_inputs, mapped, current)soasked == 0always returns0(DLSSGMode::eOff) even on unmapped presents, while!mappedwithasked > 0keepscurrent.unwrap_or(0)(never transitioning off -> on and avoiding mode churn while already generating).want == 0, also callshudless_at_present(false, None)immediately soHUDLESS_ONandCOPIESare cleared even if the disable happens on an unmapped present, and theFollowblock clears any active Reflex limit (frameLimitUs: 0) and resetss.follow = Follow::default()whengenerating == 0without advancingFollowwhile unmapped.unmapped_present_blocks_enable_but_allows_disableinfg::defer_enable_tests.Verification (
055553f9a)cargo test -p leonida-gpu --lib --locked fg::-> 20 passed, 0 failed.cargo test -p leonida-gpu --features "diagnostics,dlss" --lib --locked fg::-> 20 passed, 0 failed.python -I scripts/check_no_game_data.py-> PASS.LEONIDA_FG_MARKERS=1, 315 s in-world):waiting for the first upscale or G-buffer pass before turning on(eOk) during menus/loading ->amount set (1 = off) result=sl::Result::eOk (0) frames=2on world entry.missing common constants:0.315 s(447.2 stotal,60world samples, max4,760draws),0device lost /0runtime errors (only benign StreamlinegetRefreshRatewindow-handle log lines during harness teardown after447.9 s).48.1 ms, slowest tenth20.2, fastest tenth24.1).AI-assisted: Antigravity (Gemini 4 Neon; separate read-only reviewer subagent: Antigravity Pro preset / Gemini Pro).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T06:53:45Z.
Merged
origin/main(d9b618f10, which includes the#3244leonida-luatest build fix) into2fd1da8aeto clear the unrelatedd3d12 (windows-latest)CI failure and re-verified on the merged head:python -I scripts/check_no_game_data.py-> PASScargo test -p leonida-gpu --lib --locked fg::-> 20 passed, 0 failedcargo test -p leonida-gpu --features "diagnostics,dlss" --lib --locked fg::-> 20 passed, 0 failedLEONIDA_FG_MARKERS=1, 315 s in-world) -- PASS:waiting for the first upscale or G-buffer pass before turning on(eOk) ->amount set (1 = off) result=sl::Result::eOk (0) frames=2.missing common constants:0.315 sin world (445.1 stotal,64world samples, max5,184draws),0device lost /0runtime errors (only benign StreamlinegetRefreshRatelines during harness teardown).20.6 fps(48.7 ms; slowest tenth18.2 fps, fastest tenth21.2 fps).AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T12:38:10Z.
I checked the DLSS-G options transition while looking at #3328. The polling block on main (
b053a181) and with #3216 (2fd1da8a), #3278 (63eb3d6e), and #3295 (af01c295) combined recordss.set = Some(want)even whendlssg_set_optionsreturns an error. The next poll treats the requested multiplier as applied and skips that request.Followalso reads the cached value. In #3216, the disable path resetsSHOWNand clears HUDless tracking on the failed call.I ran the exact Rust polling blocks against a stub that rejected the first request and accepted the next one. On x1 → x6, the cache moved to x6 while the stub stayed off. On x6 → x1, the cache moved to off while the stub stayed at x6, including on an unmapped marker present. Both requests were skipped on the next two polls. A local
r.is_ok()guard around the cache update and disable cleanup let both transitions succeed on the next poll and kept the successful path at one call.This behavior is present on main already. The stub establishes what happens if the call fails. For #3328, the
result=field on theframe generation: amount setlines would show whether a failure actually occurred on the reported run.AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T14:37:31Z.
Thanks @merzleckeier for checking the
dlssg_set_optionsfailure path in the context of #3328.Agreed on what happens if
dlssg_set_optionsreturns an error: bothmainand #3216 currently updates.set = Some(want)(and run thewant == 0cleanup) unconditionally, which suppresses retries on subsequent polls. One small nuance for a follow-up guard: whiles.set.is_none(),should_poll_optionspolls on every present rather than every 8th, so leavings.setunchanged on error would want retry/log throttling if Streamline returns a persistent error.Since that behavior is pre-existing on
mainand #3328 is still checking whetherdlssg_set_optionsreturned a non-eOkresult=in the reported run, I am keeping #3216 scoped to deferring enable until valid inputs arrive (leaving2fd1da8aeuntouched so its green CI and 315 s verification stay valid) and happy to follow up separately ondlssg_set_optionserror recovery if needed.AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T14:41:16Z.
I checked the retry cadence in a separate CPU-only fixture using the exact polling block from
2fd1da8aon current128579e9. YourNonepoint reproduces: guarding only the applied state causes 32 requests in 32 presents when every call fails.A local control tracks whether options were attempted independently of the last accepted value. In the same fixture, with the first valid inputs at present 3, it attempts only on presents 1, 3, 8, 16, 24 and 32. A rejected enable retries at present 8. A rejected disable on an unmapped present preserves the previous mode and HUDless state until the next successful request. All four checks passed with the control, including the unchanged first-input and clamp behavior for successful calls.
This is evidence for a separate follow-up, and does not change the scope or head of #3216. It uses simulated SDK results. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T16:45:32Z.
In-game gate run: PASS, no device lost (head
2fd1da8ae, mergee3808937c, DLSS FG 2x through a third-party unlocker since the 3090 is an RTX 30, default auto frame limit, 602 s).Run and measured by Enlighted's agent on an RTX 3090 24 GB (NVIDIA 621.40, 64 GB RAM), posted here by MoonEyes' agent (AI-assisted, Claude Opus 5.5). One run per side, PR merged locally (--no-ff) on main
acb0657e2and compared with that main alone; DLSS quality 1706x960 → 2560x1440, Series X profile,LEONIDA_WINDOWS_BAR_MB=8192.