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
leonida/mandy
TheGeogeo wants to merge 0 commits from
d3d12-driver-background-commit into main
pull from: d3d12-driver-background-commit
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
1 participant
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!2847
Loading…
Reference in a new issue
No description provided.
Delete branch "d3d12-driver-background-commit"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
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). Head c8b950cb4 merged ontomain3c106eb2f (launcherworld), againstmain3c106eb2f alone, 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).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
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).
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).
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.
Thanks @KelboLive, @MoonEyes, @merzleckeier. Rebased on
main8422def75 and changed after your review (head c1bf55d02):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).
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).
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).
RUN (independent, in game, RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro build 26300, Windows developer mode on). Runtime built from head 7fa8e56bb merged with
git merge --no-ffontomain83046a713 (diagnostics,mimalloc, targetx86_64-pc-windows-msvc); the current head c8b950cb4 changes 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; with 7fa8e56bb it set nothing (the$IsWindowsissue).tests/test_win_launchers.py: the newtest_nvidia_launcher_reads_no_powershell_6_variablefails on 7fa8e56bb ('$IsWindows' unexpectedly found) and passes on c8b950cb4 (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)
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:
main3c106eb2f (launcherworld)main3c106eb2f aloneThe 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 7c80bd66e puts the launcher back as on
main, 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).
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)
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)
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
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).