leonida-gpu: LEONIDA_D3D12_BACKGROUND keeps the driver's background shader work out of the world, as a switch (D3D12-DRIVER-BACKGROUND-PLAY) #2847
Closed
TheGeogeo wants to merge 8 commits from
upstream-pr/2847 into main
pull from: upstream-pr/2847
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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.
Reference
ProjectLeonida/mandy!2847
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2847"
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 TheGeogeo on 2026-12-01T07:59:41Z.
Claimed in the coordination issue as:
D3D12-DRIVER-BACKGROUND-PLAY(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7302676817)What and why
After pipelines are made or loaded, the driver compiles their shaders again on threads of its own in this process ("D3D Background Thread"s) and keeps the result in its own cache. Until that is done for the translations in use, those threads take one or two processors: 9 to 15 minutes of play after each change of translations, on a processor the title already fills.
This pull request makes that work a switch to choose. It is not a new default: the launcher and the runtime leave the driver as it is unless
LEONIDA_D3D12_BACKGROUNDis set.0: never. Set on the title's device when it is made (the call that was inhost.rs).world: off while the world is drawn, allowed in loading screens and menus. The world is counted as the game gate counts it:draw::drawn, 500 draws a frame, 2 counts of 0.5 s to enter, 10 to leave.LEONIDA_ABcan name it, for in-run A/B.d3d12/crates/leonida-gpu/src/driver_background.rsholds all three.host.rskeeps one call.queue::presented()is available outside diagnostics builds.Windows switches the work off only in Developer mode. Microsoft's page of
D3D12_BACKGROUND_PROCESSING_MODEsays ofDISABLE_BACKGROUND_WORK: "Available only in Developer mode." Elsewhere the call fails; Kal0s-design measured0x887a002don every adapter, whileALLOWEDsucceeds. The refusal is written once at WARN with its code, naming Developer mode, and the thread stops asking.Why it is not a default. The first measurements (below) saw a gain on the submitting thread. Two later checks on the merge with
mainsaw more long frames with the work off while the driver still had some:The assumption, not measured, is that with the work off the driver does at a pipeline's creation what it would otherwise do in the background. Both numbers are in
findings.md, so a player or a later change can choose.Measured
RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 with Developer mode on, Series S settings, standing, gate runs with the driver mod.
The slow phase (2026-12-01).
On the merge with
main(2026-12-02). Headc8b950cb4merged ontomain3c106eb2f(launcherworld), againstmain3c106eb2falone, one gate run each, 300 s in the world:worldmainThe long frames came while pipelines were made in the world (1 to 2.4 a second). With one run each, and the first run of the pair being this change, this is a sign, not a proof. It agrees with enlight3d's 3090 A/B: 73 frames over 50 ms with the work off against 42 allowed in the first ~300 s, and a 90th percentile 0.65 ms better allowed, while allowing it cost the submitting thread about 1 ms.
Tested
On Windows 11, from
d3d12\with the pinned toolchain:cargo test -p leonida-gpu --locked --lib: 676 passed, 0 failed, 59 ignored.texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriersfails; it is green alone, and plainmainshows the same.--features diagnostics: 747 passed.driver_background::tests, 8 tests: the variable's values; the decision with and without an A/B phase; the world's hysteresis; each count judging only its own frames; a count without frames;WORLD_DRAWSread fromtools/game_gate.py; a mode asked for only when it changes; a refusal reported once and not asked again.WORLD_DRAWSat 50; the counter's mark not moved on.cargo clippy -p leonida-gpu --all-targets --locked: no warning in the changed files.tools/d3d12_switches.py --check,tests/test_win_launchers.py(launcher unchanged frommain), andscripts/check_no_game_data.pyon the changed files.world, the log saysallowed=trueat start andallowed=falseat world entry.GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 26300 (Developer mode on). Also RTX 3090 / 621.40 by enlight3d, and the refusal without Developer mode by Kal0s-design.
AI-assisted: yes. Claude Code with Claude Fable 5.2 and Claude Opus 5.5; the diff was reviewed by a separate Claude Opus 5.5 agent.
Checklist
mainand merges cleanly.docs/design.md(no translator change here).Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T09:27:55Z.
RUN
Verdict:
sameon 16C/32T (Ryzen 9 5950X) -- no statistically clear median frame-time difference in matched alternating 20 s phases, with zero errors, zero device-lost events, and clean cold PSO precompile.Setup:
#2847head3a9afee52merged ontomainad7c62edb(featuresdiagnostics,dlss,mimalloc)LEONIDA_AB=20,LEONIDA_D3D12_BACKGROUND(Series S,-NoFrameGen)621.40, Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T)Unit test:
cargo test --locked -p leonida-gpu --lib driver_backgroundpassed.In-run A/B (
tools/d3d12_ab_compare.py phases):-0.220 +- 0.220 ms(no clear difference)27.6 fps/36.2 ms(gpu_wait 0.0 ms, max4,214draws,475.6 scold precompile on fresh translations,30world samples,0errors,0device lost)World phases (
draws >= 1000):LEONIDA_D3D12_BACKGROUNDWith 32 hardware threads on Ryzen 9 5950X, there is ample CPU headroom for driver background threads compared to 6C/8C CPUs, so
samemedian on 16C/32T with zero regressions is expected and confirms stability on RTX 5070 + driver621.40.AI-assisted: Antigravity
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T14:25:12Z.
RUN (RTX 4060 8 GB, NVIDIA 610.88, Windows 11 26300,
-SeriesS -FrameGen 2, about 860 s in the world, 0 device lost): head3a9afee52with six others onmain21e6bbf4b.The switch never took effect here.
LEONIDA_D3D12_BACKGROUND=worldwas set (launcher default of this pull request), the world drew 3,500 to 4,700 draws a frame by the five-second lines, and the log has one line only, at the start:allowed=true. There is noallowed=falsein 14 minutes of world. Instart(), aset_mode(false)that fails is tried again every 500 ms without a word, so that is my guess (not checked):SetBackgroundProcessingModerefusesDISABLE_BACKGROUND_WORKhere. Could the thread log the HRESULT once, and does the mode need something on the machine (Developer Mode, for example)? Developer Mode is not set in the registry here.No harm seen: no loss, no panic. But I can not confirm the effect.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T14:37:08Z.
I checked the actual HRESULT for the mode changes in
3a9afee5+cd0c52fcf. On RTX 4070 SUPER (620.73.04) and AMD Raphael (RADV 26.3.1), Wine 11.22 and VKD3D-Proton exposedID3D12Device6.SetBackgroundProcessingMode(ALLOWED / DISABLE_BACKGROUND_WORK / ALLOWED, KEEP_ALL, null, null)returnedE_NOTIMPL(0x80004001) for all three calls on each GPU. The four policy tests also passed.For the native Windows question, Microsoft documents that
DISABLE_BACKGROUND_WORKis available only in Developer Mode. That fits the reported native pattern of an initialallowed=truewithout a later successful disable. The native HRESULT is still unmeasured here. A one-time log of the attempted mode and HRESULT would distinguish that case from a missed threshold. Microsoft D3D12_BACKGROUND_PROCESSING_MODE documentationMEASURED with offscreen synthetic devices under Wine. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T17:58:15Z.
Review: CHANGES_REQUESTED
The draw-counter and docs side is consistent:
WORLD_DRAWS = 500.0matchestools/game_gate.py:22and its two-line rule,ENTER/LEAVE2/10 × 0.5 s matches the text, the frame log stays exact (list.rs:2541-2551, no new atomic oncount_draw), and 604 tests pass (the 2 diagnostics failures are the known parallel flakes, green alone).Blocking: the mechanism is restricted to Windows Developer Mode, and the failure is silent.
D3D12_BACKGROUND_PROCESSING_MODE_DISABLE_BACKGROUND_WORKis documented as requiring Developer Mode.set_modediscards the HRESULT (driver_background.rs:153-167), the caller logs only on success (:139-147) and retries every 500 ms. On a default Windows install that produces exactly theallowed=truethen silence MoonEyes reported, and matches merzleckeier'sE_NOTIMPL— the PR's successfulallowed=falserun implies a machine where it was permitted. Neitherfindings.mdnorswitches.mdmentions the precondition, andplay-nvidia.ps1:278now defaults the launcher toworld, so for most users the headline feature is a silent no-op that looks like it worked.Please:
Developer Modenamed in the message), instead of retrying into silence;findings.mdandswitches.md;worldlauncher default until a run on a non-Developer-Mode install confirms the mode actually changes — or make the default conditional on a successful probe.Also,
WORLD_DRAWS = 500.0mirrors the gate only by comment: mutating it to50.0leaves all fourdriver_backgroundtests green, so nothing pins the "as the game gate counts it" claim. A test that imports the number fromgame_gate.py(or asserts the same value) would.Minor:
driver_background.rs:11says "~9 minutes" while findings/body say "9 to 15", andfindings.md:1731says a repeat run "has none" then that the threads stop about 45 s after the world comes up — reword that pair.Merge is clean against current main and the merged tree still passes
d3d12_switches.py --check; #2888 and #2743 conflict only infindings.md(and #2743 alsoswitches.md).Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T00:45:22Z.
VERIFY-2847 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files
Verdict: PASS. The switch's rules are readable and the counting they need is there, the new tests pass, and nothing that worked before is broken. The measurements the pull request quotes are a claim about an NVIDIA card and the game, and I could not check them.
Head
3a9afee5, base the currentmain85ec1d33, merge base501b3e6c, 8 files, +310/−7:d3d12/crates/leonida-gpu/src/driver_background.rs(new),d3d12/crates/leonida-gpu/src/list.rs,d3d12/crates/leonida-gpu/src/host.rs,d3d12/crates/leonida-gpu/src/queue.rs,d3d12/crates/leonida-gpu/src/lib.rs,d3d12/docs/findings.md,d3d12/docs/switches.md,d3d12/scripts/play-nvidia.ps1.1. What it changes
After the pipelines are made or loaded, the driver compiles their shaders again on threads of its own in this process, and until it has done so those threads take one or two processors — on a processor the title already fills, that costs the frame. The new module lets that work be switched off, or paused while the world is drawn:
LEONIDA_D3D12_BACKGROUND=0— never (the mode is set when the device is made);LEONIDA_D3D12_BACKGROUND=world— not while the world is drawn, allowed in loading screens and menus;1— the driver's own behaviour, as before (nothing is started);LEONIDA_ABmay name the switch, and its phase wins over the policy.2. What I checked
The policy mapping.
unset and
1both giveAlways, andstart()returns early forAlwaysunlessLEONIDA_ABnames the switch — so the default path starts no thread at all and the driver is left as it was ✓, which is what the documentation says.The world is recognised with hysteresis.
World::countcomparesdraws / frameswithWORLD_DRAWS = 500, and a count with no frame (frames == 0) changes nothing ✓ — so a period with no rendering cannot flip the state. The asymmetry (two counts in, ten out) is deliberate and is in the comment: the work is switched off quickly when the world is drawn and allowed again slowly, so a loading screen between two world stretches does not start the work again and stop it again.The phase wins over the policy.
phaseisLEONIDA_AB's phase for the switch; when the switch is not named inLEONIDA_AB,phase()isNoneand the policy decides ✓.The counting it needs is there.
list.rs'stake_counts()used to reset the draw counter; it now keeps its own mark and returns the difference, and a newdraws_so_far()gives the total since the start — which is what the world test needs (draws / frames) ✓.3. What the tests do here
leonida-gpudoes not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled it forx86_64-pc-windows-gnuand ran the tests under Wine 11.21.The pull request changes no test, so the red side cannot be built (there is nothing to take); the base and the head were compared instead:
watchtests that need Microsoft'sVirtualAlloc/VirtualQuerybehaviour, which Wine does not haveOne further test,
watch::tests::a_write_is_reported_at_every_checked_view, failed in one full-suite run on the head and passed on the base. It is the same family of parallel-run flakes as the three above: run alone it passes 5 times out of 5 on the head, and the same test fails on the base at a comparable rate when the whole suite runs in parallel.4. What I did not check
D3D12_MEASUREMENTS_ACTION_COMMIT_RESULTS_HIGH_PRIORITYexperiment — these are from an RTX 3080 with the game, and neither the card nor the game is here.0path setsD3D12_BACKGROUND_PROCESSING_MODE_DISABLE_BACKGROUND_WORKon the device when it is made (the pre-existing code), and theworldpath sets it again from the new thread; whether that is what the driver's threads read is a driver property.WORLD_DRAWS = 500is the game gate's "the world is drawn" measure (tools/game_gate.py); I did not check that the draw counts the module reads are the same ones the gate uses.AI-assisted: MiniMax M3.1 Flash.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-12-02T03:42:36Z.
Thanks @KelboLive, @MoonEyes, @merzleckeier. Rebased on
main8422def75and changed after your review (headc1bf55d02):D3D12_BACKGROUND_PROCESSING_MODEsays ofDISABLE_BACKGROUND_WORK: "Available only in Developer mode." The PC I measured on has it on; the RTX 4060 run had it off, and the first version wrote only calls that succeeded and asked again every half second, which is why it showedallowed=trueand nothing more. Now a refused call is written once at WARN with its code (the driver's background shader work stays as the driver likes, naming Developer mode and where to turn it on), and the thread stops asking. The precondition is in the module,findings.md,switches.mdand the launcher.0takes the same path. The call that was inhost.rsmoved intodriver_background::start, whichhost.rscalls once:0is still set when the device is made, before anything is made with it, and a refusal is written the same way. One parser for the variable.play-nvidia.ps1setsworldonly where Developer mode is on (AppModelUnlock\AllowDevelopmentWithoutDevLicense= 1); elsewhere the driver is left as it is, so players without Developer mode see no change and no warning.-Morestill applies on top.draw::drawn, the gate's figure), so thelist.rschange is gone. A test readsWORLD_DRAWSfromtools/game_gate.pyand checks one draw a frame below it is not the world; with the constant at 50 it fails. Another test covers a long world stretch followed by a menu.worldsession the defaults' threads still ran 14 minutes, so for some players it may never finish. On the 3080 that costs the card nothing measurable (29.5 ms of card work a frame with shaders the driver never got to, 30.4 ms with its finished ones).Tested on the RTX 3080 (driver 32.0.16.2140, Windows 11, Developer mode on): crate tests and diagnostics tests, three mutations each caught by a test, and a 300 s gate run of this code: PASS,
allowed=trueat start,allowed=false78 s later at world entry. Not tested: the refusal on a PC without Developer mode. @MoonEyes, if you run it again on the 4060 with-More @{LEONIDA_D3D12_BACKGROUND='world'}, the log should have one WARN line with the code at world entry and nothing after it.AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5; a separate Claude Opus 5.5 agent reviewed the diff before this push).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:29:03Z.
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T13:19:55Z.
Ran natively on Windows 11, head
7fa8e56bbmerged into currentmain(d0bf821fa, clean merge), Windows without Developer mode (AppModelUnlock\AllowDevelopmentWithoutDevLicensenot 1). No game run; this covers the refused path the body lists as not tested, plus the launcher's Developer mode check.The native refusal code. A throwaway test calling the PR's
set_modeon every adapter this PC enumerates (the NVIDIA card, a second hardware adapter, Microsoft Basic Render, WARP):ALLOWEDS_OKDISABLE_BACKGROUND_WORK0x887a002d(DXGI_ERROR_SDK_COMPONENT_MISSING)ALLOWEDS_OKDISABLE_BACKGROUND_WORK(twice)0x887a002dboth timesALLOWEDS_OKSo here, with Developer mode off, native Windows refuses only the switch-off, with
0x887a002d, notE_NOTIMPLas under Wine.Mode::turndriven by the real device givesNow(true),Refused(false, 0x887a002d),Same,Same. Withworldthat means:allowed=trueat start, then one WARN line at world entry, then the thread ends. This matches the earlier native report in this thread and what the fix expects.The launcher's Developer mode check is always false in Windows PowerShell 5.1.
play-nvidia.ps1:403:$IsWindowsonly exists in PowerShell 6+. In Windows PowerShell 5.1 it is unset ($null), so the whole expression isFalse, whatever the registry says:$IsWindows$IsWindows -and $trueFalseTrueTrueThe documented route runs 5.1.
Launcher.batgoes totools/leonida_launcher.py, whoseplay_commandstartspowershell -File scripts\play-d3d12.ps1. That script calls& ...\play-nvidia.ps1in the same 5.1 process. The README'spowershell -ExecutionPolicy Bypass -File ...line is 5.1 too. So on that route theworlddefault is dropped even where Developer mode is on. Nothing breaks; the default is just never applied. No test intests/covers this line (test_win_launchers.pyhas no Developer mode case, and it preferspwshwhen installed). The script is Windows-only, so the$IsWindows -andpart can go, or$env:OS -eq 'Windows_NT'works in both shells. UnderSet-StrictMode -Version Latest(used for the body's check), 5.1 throws on$IsWindowsinstead (The variable '$IsWindows' cannot be retrieved because it has not been set). The launcher sets no strict mode, so in practice the result is the silentFalse.Tests on the merge:
cargo test -p leonida-gpu --locked --lib--features diagnosticswatch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view, green alone 3 of 3 (parallel flake, not in this diff)driver_backgroundtests,--features diagnosticscargo clippy -p leonida-gpu --all-targets --lockeddriver_background.rsorqueue.rstools/d3d12_switches.py --check,tests/test_win_launchers.pyThe new tests do not exist on
main(new module), so there is no red side to compare.Not checked: any in-game run or frame time; the switch-off path with Developer mode on (not enabled here); whether the debug layer adds a message to the refusal.
GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-02T16:02:31Z.
RUN (independent, in game, RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro build 26300, Windows developer mode on). Runtime built from head
7fa8e56bbmerged withgit merge --no-ffontomain83046a713(diagnostics,mimalloc, targetx86_64-pc-windows-msvc); the current headc8b950cb4changes no file underd3d12/crates(only the launcher's developer-mode line and its test), so the same runtime code.Launcher, head
c8b950cb4. A dry run under Windows PowerShell 5.1 (-SeriesS -NoDlss -NoFrameGen) now setsLEONIDA_D3D12_BACKGROUND=worldon this PC; with7fa8e56bbit set nothing (the$IsWindowsissue).tests/test_win_launchers.py: the newtest_nvidia_launcher_reads_no_powershell_6_variablefails on7fa8e56bb('$IsWindows' unexpectedly found) and passes onc8b950cb4(6 passed).cargo test -p leonida-gpu --libon the merge: 704 passed, 0 failed (785 withdiagnostics), the 8driver_background::testsincluded.The cut happens. Warm-up run with
LEONIDA_D3D12_BACKGROUND=world:allowed=true1.3 s after start,allowed=false1.3 s after reaching the world; no refusal line.Effect on the frames, Series S settings, standing at the save, one run of 900 s right after the warm-up (same driver cache), measured,
LEONIDA_AB=10,LEONIDA_D3D12_BACKGROUND(phases with the driver's background work allowed, as onmain, and cut, as this pull request does in the world),LEONIDA_LOG=info,leonida_gpu::frame=debugfor one line per present, first 30 s after reaching the world left out, 40 pairs of phases. Differences are allowed − cut.No crash, no device loss, private memory at most 29.1 GB.
Reading for this card: cutting the driver's background work in the world did not make frames steadier here. While the driver still had work (the first minutes after reaching the world), there were more frames over 50 ms with it cut than allowed (73 against 42), and the p90 was a little lower with it allowed; allowing it costs the submitting thread about 1 ms a frame meanwhile. Afterwards the two are the same. The split at about 300 s is an estimate (when the driver's background thread finished was not sampled), but the difference in long frames is gone after it. One run on one card; it does not contradict a gain on another card or driver, it only does not reproduce one here.
Verdict for this card: no regression in stability, no gain in steadiness measured.
AI-assisted: Claude Code (Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-12-02T16:05:34Z.
RUN, as asked by @MoonEyes. RTX 3080 10 GB, NVIDIA 32.0.16.2140, Windows 11 Pro 26300 (Developer mode on), Series S settings, standing, the gate's driver mod. One run each, 300 s in the world:
c8b950cb4merged ontomain3c106eb2f(launcherworld)main3c106eb2faloneThe log shows
allowed=trueat start andallowed=falseat world entry. The long frames came while pipelines were made in the world, at 1 to 2.4 a second. That is one run each, and this change ran first. But it points the same way as @enlight3d's 3090 A/B: more frames over 50 ms with the work off while the driver still had some.So the default goes. Head
7c80bd66eputs the launcher back as onmain, which also removes the Developer mode check that @Kal0s-design's 5.1 finding was about.0,worldandLEONIDA_ABstay as switches, with the refusal written once; thanks @Kal0s-design for the native code,0x887a002d.findings.mdrecords both checks and the refusal code. The description and the title now say it is a switch, not a default.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by valenciana-nc on 2026-12-02T16:46:11Z.
A launcher bug at head
7fa8e56bb: under Windows PowerShell 5.1,worldis never set.d3d12/scripts/play-nvidia.ps1:415reads:$IsWindowsis an automatic variable of PowerShell 6 and later only. In Windows PowerShell 5.1 (powershell.exe) it doesn't exist, so it reads as$nulland$developerModeis always false. The next line then removesLEONIDA_D3D12_BACKGROUND. 5.1 is what the README's start command (powershell -ExecutionPolicy Bypass -File scripts\play-d3d12.ps1 ...) andLauncher.batrun.Checked on Windows 11 with Developer mode on (
AllowDevelopmentWithoutDevLicense= 1):powershell -NoProfile -Command '$PSVersionTable.PSVersion; $null -eq $IsWindows'gives5.1.26100.10068andTrue.-DryRunof this head merged ontomain(-SeriesS -Resolution 720) prints noLEONIDA_D3D12_BACKGROUNDline.A form that works in both:
[Environment]::OSVersion.Platform -eq 'Win32NT'also works.Why it matters here: on this PC (RTX 4060 Laptop 8 GB, 16 GB RAM, 621.47) the device loss of #2821 came after 3.7–8.5 min in 5 of 6 runs without background work off, and none came in 30–45 min in 5 runs with
LEONIDA_D3D12_BACKGROUND=0or with allocator trim. Numbers are in https://github.com/ProjectLeonida/mandy/issues/2821#issuecomment-7352177565. So this switch may matter for stability, not only for processor time. I'm now running this head withLEONIDA_D3D12_BACKGROUND=worldset by hand and will post the in-game report here.AI-assisted: yes (Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by valenciana-nc on 2026-12-02T17:34:14Z.
In-game run report for #2847, as @MoonEyes asked.
7fa8e56bbmerged ontomain83046a713(clean merge), diagnostics build.scripts\play-d3d12.ps1 -SeriesS -Resolution 720 -NoDlss -NoFrameGen, withLEONIDA_D3D12_BACKGROUND=worldset by hand. Under Windows PowerShell 5.1 the launcher doesn't set it itself (see my comment above about$IsWindows).LEONIDA_D3D12_DRED=light.In both runs the runtime logged
allowed=truewhile loading andallowed=falseabout 50 s later, once the world was drawn. It stayed that way to the end; there were no loading screens in between.For comparison, the same PC, settings and loop without this PR, on
main-based builds (numbers in https://github.com/ProjectLeonida/mandy/issues/2821#issuecomment-7352177565):maind0bf821fa, standing.LEONIDA_D3D12_BACKGROUND=0, 2 of 2 ran 30 to 45 min with no loss, at 23.0 to 23.2 fps median.This PR's
worldmode behaves like0here, with no loss in 2 of 2 runs of 20 min, and the frame rate is the same as with0. One caveat: like every run of these series, the system commit was near its limit (the PC has 16 GB).AI-assisted: yes (Claude Opus 5.5; runs driven by script on the PC above)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:29:37Z.
Verification of #2847 (LEONIDA_D3D12_BACKGROUND: world, 0 and A/B): third-party code review on Linux x86_64. The code was not built:
leonida-gpuis Windows-only.7c80bd66e, merge base8422def75. It merges cleanly intomain45dc41f95. CI passes on this head (6/6).7fa8e56bb, the head of the in-game runs posted above, and the current head, onlyd3d12/docs/findings.md,d3d12/docs/switches.mdandd3d12/scripts/play-nvidia.ps1changed (git diff --stat). The launcher change was dropped.leonida-gpuis therefore identical to what was run in game, and the PowerShell 5.1$IsWindowsproblem reported above no longer applies.Commands and results
python -I tests/test_d3d12_switches.pyon the merge: 20 tests, OK.python -I scripts/check_no_game_data.pyondriver_background.rs,host.rs,findings.mdandswitches.md: clean.Review (
d3d12/crates/leonida-gpu/src/driver_background.rs)startmakes no call when the variable is unset or1and A/B does not name the switch (L182). Behaviour then matchesmain, except that the old inline=0path now goes throughset_modeand logs a refusal once.World::countuses hysteresis: 2 counts to enter, 10 to leave, 500 draws a frame, the same asWORLD_DRAWSin the game gate. It ignores intervals with no new frame.Mode::turnstops asking after the first refusal, which is right outside Developer mode.queue::presentedloses its#[cfg(feature = "diagnostics")]so that release builds can count frames;draw::drawnwas already unconditional.worldor A/B is set. A0.5 ssleep loop is cheap, so this is acceptable.0orworldsilently means "allowed". A warning for a value it does not recognise would help users who typeoff.Verdict: ready on code review (not built here: Windows-only). The in-game runs on code identical to this head are posted above.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-12-03T00:08:31Z.
Closing this. As a default it did not help: on the merge with
main, the RTX 3080 here and @enlight3d's RTX 3090 both saw more long frames with the work off while the driver still had some. And Windows refuses the switch-off outside Developer mode (0x887a002d, thanks @Kal0s-design), so few players could use the switch.@valenciana-nc's RTX 4060 Laptop runs point at stability, not frame time (
0andworldheld 20 to 45 min wheremainlost the device in 5 of 6 runs). That lead stays in #2821.The branch
TheGeogeo:d3d12-driver-background-commit(7c80bd66e) keeps the switch, its tests and the refusal logged once, for anyone who wants to carry it on. Thanks to everyone who ran and reviewed it. The claim is released in #2570.AI-assisted (Claude Code, Claude Opus 5.5).
Pull request closed