Skip to content

d3d12: opt-in precompile of every known pipeline (-PrecompileAll); never-drawn pipelines stay out of the library - #2986

Open
TheStonedGamer wants to merge 3 commits into
ProjectLeonida:mainfrom
TheStonedGamer:precompile-all
Open

TheStonedGamer wants to merge 3 commits into
ProjectLeonida:mainfrom
TheStonedGamer:precompile-all

Conversation

@TheStonedGamer

Copy link
Copy Markdown

Claimed in the coordination issue as: D3D12-PRECOMPILE-ALL-PIPELINES (#2570 (comment))

What and why

The precompile before a start (leonida warm --used) makes only the pipelines earlier runs drew with. A place or effect not drawn in before then compiles its pipelines while the game waits.

  • -PrecompileAll (Launcher.bat: "Precompile every pipeline", off by default) runs leonida warm without --used: every pipeline the title has created in any run (known-pipelines.bin, 88,586 here against about 4,000 drawn with) is compiled into the driver's cache. Plumbed through tools/leonida_launcher.py, scripts/play-d3d12.ps1 and d3d12/scripts/play-nvidia.ps1 (kept across the F1 menu's restart). It prints that the first run takes an hour or more and that NVIDIA's Shader Cache Size should be Unlimited. Documented in README.md, docs/launcher.md and d3d12/README.md.
  • warm.rs: only pipelines earlier runs drew with go into the pipeline library (into_library()); the rest stay in the driver's cache alone. The driver checks an entry of its own cache against the pipeline asked for and compiles again where they differ, while a library entry is taken as stored. With every known pipeline in the library (1.5 GB, 91,525 entries), the device was removed twice during a burst of first loads in a new place: no hang (no TDR in the event log), no page fault in DRED, the library file whole (0 of 366,955 pages read as zeros). With them kept out, the same settings stayed up. The cause inside the driver is not known. With --used (the default) nothing changes: those keys are already only ones drawn with.

Tested

  • cargo test --locked -p leonida --bin leonida warm:: — the new only_pipelines_drawn_with_go_into_the_library fails with the early condition removed (the old rule without --used) and passes with it (reverted by hand; MEASURED).
  • python -m unittest tests.test_leonida_launcher tests.test_win_launchers: OK, including the new test_precompile_all_only_with_the_precompile and -PrecompileAll in the switch check against play-d3d12.ps1. python -m unittest discover -s tests -p "test_docs_*.py": OK. python -I scripts/check_no_game_data.py on the changed files: clean.
  • In the game (MEASURED, one machine): a full precompile of 88,586 pipelines, then a run with the library limited to those drawn with: stable, 28 pipelines compiled while playing against 3,851 loaded from the library; before the warm.rs change, two device removals as above.

GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 621.40, Windows 11 Pro (26300)

AI-assisted: yes (implementation: Claude Opus 5.5 via Claude Code; separate read-only reviewer agents: Claude Opus)

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md (n/a: no translator change).

🤖 Generated with Claude Code

TheStonedGamer and others added 3 commits December 1, 2026 17:30
The precompile makes only the pipelines earlier runs drew with (warm --used).
-PrecompileAll (launcher: "Precompile every pipeline", off by default) makes
every pipeline the title has created, as foxhound's launcher does: fewer
stalls in places not drawn in yet, at the cost of an hour or more and
gigabytes the first time. Kept across the F1 menu's restart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With -PrecompileAll every known pipeline is made (some 88,000 against 4,000
drawn with). Those never drawn with now stay in the driver's cache alone and
are kept out of the pipeline library: the driver checks an entry of its own
cache against the pipeline asked for and compiles again where they differ,
while a library entry is taken as it was stored.

With them in the library (1.5 GB, 91,525 entries) the device was removed
twice during a burst of first loads in a new place (RTX 3060, driver 621.40):
no hang, no page fault, the library file whole. With them kept out, a run of
the same settings stayed up. The cause inside the driver is not known.

The rule is into_library(), with a unit test that fails without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tests: -PrecompileAll is among the switches checked against play-d3d12.ps1,
  and it is passed only with the precompile on.
- README.md, docs/launcher.md, d3d12/README.md: the switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrew-ai

Copy link
Copy Markdown

Integration check with #2956. Both public Windows launchers default to the same sequence but implement the opt-in full precompile differently. I ran the unchanged scripts on each head with a synthetic recording executable.

PR and options Invocations in order
Either PR, default shaders, warm --used, run
#2986 -PrecompileAll shaders, warm, run
#2986 -PrecompileAll -NoPrecompile run
#2956 -WarmAll shaders, warm --used, warm with LEONIDA_WARM_LIBRARY=0, run
#2956 -WarmAll -WarmOnly shaders, warm --used, warm with LEONIDA_WARM_LIBRARY=0

git merge-tree on afe0b79 and 558b798 reports content conflicts in README.md and both scripts (scripts/play-d3d12.ps1 and d3d12/scripts/play-nvidia.ps1). The functional distinction matters when resolving those conflicts: this PR chooses library eligibility inside warm, while #2956 enforces it by splitting the passes. Combining both launcher implementations literally risks repeating a full warm. This check measured routing only, with no title, shader data or driver-cache workload. Codex-assisted for #2570.

@merzleckeier

Copy link
Copy Markdown
Contributor

The full-precompile choice survives the actual saved F1 arguments.

I tested afe0b798f453e7c707f5177275be1b72f862a3a5 on main 1abef08d using the unmodified PowerShell wrapper and inner launcher, a synthetic recording executable, and Linux PowerShell 7.4.21. Each successful cell replayed the actual LEONIDA_MENU_ARGS captured at process start.

Input First start F1 replay
Default or -PrecompileAll:$false warm --used warm --used
-PrecompileAll warm warm
-PrecompileAll -NoPrecompile no shader or warm command no shader or warm command
-PrecompileAll with a missing noted cache file warm --again warm after the stub recreated the file

The combination with #2761 also launched the dynamic preset with -MotionBlur:$false -PrecompileAll. Both starts kept 2560×1440, minimum scale 0.75, and four MotionBlur skip entries, and both issued bare warm. Stock Python launcher tests passed 15/15 on main and 16/16 in each PR tree. These runs cover command selection and replay with synthetic inputs. AI-assisted, independently verified against the raw results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants