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
github-bot
wants to merge 8 commits from
github-bot/gh-2847 into main
AGit
pull from: github-bot/gh-2847
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
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
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
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.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2847
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@TheGeogeo on GitHub · 2026-12-01 07:59 UTC · original
TheGeogeo:d3d12-driver-background-commit→main· +478 −23 · 6 files · 8 commits · closed without mergingClaimed in the coordination issue as:
D3D12-DRIVER-BACKGROUND-PLAY(#2570)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).@lixonik on GitHub · 2026-12-01 09:27 UTC · original
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
@MoonEyes on GitHub · 2026-12-01 14:25 UTC · original
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).
@merzleckeier on GitHub · 2026-12-01 14:37 UTC · original
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).
@KelboLive on GitHub · 2026-12-01 17:58 UTC · original · requested changes
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).@imShangLi on GitHub · 2026-12-02 00:45 UTC · original
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.
3a9afee523toc1bf55d029@TheGeogeo on GitHub · 2026-12-02 03:42 UTC · original
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).
The launcher tests run under PowerShell on Linux too, where Microsoft.Win32.Registry throws ("Registry is not supported on this platform"). The read is now behind $IsWindows.@MoonEyes on GitHub · 2026-12-02 12:29 UTC · original
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).
@Kal0s-design on GitHub · 2026-12-02 13:19 UTC · original
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).
@enlight3d on GitHub · 2026-12-02 16:02 UTC · original
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)
leonida-gpu: the driver's background shader work stays out of the world (D3D12-DRIVER-BACKGROUND-PLAY)to leonida-gpu: LEONIDA_D3D12_BACKGROUND keeps the driver's background shader work out of the world, as a switch (D3D12-DRIVER-BACKGROUND-PLAY)@TheGeogeo on GitHub · 2026-12-02 16:05 UTC · original
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).
@valenciana-nc on GitHub · 2026-12-02 16:46 UTC · original
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 #2821. 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)
@valenciana-nc on GitHub · 2026-12-02 17:34 UTC · original
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 #2821):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)
@MoonEyes on GitHub · 2026-12-02 18:29 UTC · original
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
@TheGeogeo on GitHub · 2026-12-03 00:08 UTC · original
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