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

Merged
TheStonedGamer merged 3 commits from upstream-pr/2986 into main 2026-12-02 05:33:34 +00:00
TheStonedGamer commented 2026-12-01 22:31:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheStonedGamer on 2026-12-01T22:31:23Z.


Claimed in the coordination issue as: D3D12-PRECOMPILE-ALL-PIPELINES (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7327963652)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5595790222 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2986). Originally posted by [TheStonedGamer](https://github.com/TheStonedGamer) on 2026-12-01T22:31:23Z. --- Claimed in the coordination issue as: D3D12-PRECOMPILE-ALL-PIPELINES (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7327963652) ### 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 - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] 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](https://claude.com/claude-code)
andrew-ai commented 2026-12-01 22:33:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T22:33:19Z.


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 afe0b798f and 558b7980e 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328016933 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2986#issuecomment-7328016933). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T22:33:19Z. --- 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 afe0b798f and 558b7980e 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 commented 2026-12-01 22:41:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T22:41:15Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328196062 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2986#issuecomment-7328196062). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T22:41:15Z. --- 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.
OreoFR commented 2026-12-02 04:57:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T04:57:16Z.


Smoke test of -PrecompileAll (oreofr-agent, AI-assisted): head merged into current main 8422def759cda12c89f918438eeb8d53dd5972a6, RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H. Short run only: I stopped it after 90 s, so this does not measure in-game stutter.

  • Fresh data folder with only known-pipelines.bin and known-shaders.bin; the exe in a new folder, so the driver cache started cold.
  • The launcher prints the warning, then 88568 pipelines known, 0 made before, 0 bad; 88568 to make, 14 processes. That is the whole list, without --used.
  • Speed: 1,000 pipelines in 26 s and 2,000 in 54 s, about 37 per second. The whole list would take about 40 minutes on this machine.
  • Nit: the heading line above it still reads "Precompiling the pipelines earlier runs drew with ..." when -PrecompileAll is set.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7335428598 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2986#issuecomment-7335428598). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-02T04:57:16Z. --- **Smoke test of `-PrecompileAll`** (oreofr-agent, AI-assisted): head merged into current main `8422def759cda12c89f918438eeb8d53dd5972a6`, RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H. Short run only: I stopped it after 90 s, so this does not measure in-game stutter. - Fresh data folder with only `known-pipelines.bin` and `known-shaders.bin`; the exe in a new folder, so the driver cache started cold. - The launcher prints the warning, then `88568 pipelines known, 0 made before, 0 bad; 88568 to make, 14 processes`. That is the whole list, without `--used`. - Speed: 1,000 pipelines in 26 s and 2,000 in 54 s, about 37 per second. The whole list would take about 40 minutes on this machine. - Nit: the heading line above it still reads "Precompiling the pipelines earlier runs drew with ..." when `-PrecompileAll` is set.
OreoFR commented 2026-12-02 05:13:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T05:13:12Z.


Merging (oreofr-agent, with OreoFR's written OK as maintainer): head afe0b798f453e7c707f5177275be1b72f862a3a5 merged into current main 8422def759cda12c89f918438eeb8d53dd5972a6 with no conflicts. CI green on the head.

Safe to merge into main?

  1. It merges cleanly.
  2. CI is green.
  3. -PrecompileAll is off unless asked for. With the default precompile (--used), the library filter in warm.rs keeps the same set as before: !used || early reduces to early. The new unit test covers this.
  4. tests/test_leonida_launcher.py passes 16/16 locally. The smoke test above shows the switch reaches warm with the whole list.
  5. Scope: launcher, warm.rs and docs.

Not done: no full 300 s game run. The default path's library set is unchanged, and timing the full precompile (about 40 min here) was skipped at the maintainer's request.

Going into the merge queue with #2756.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7335705499 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2986#issuecomment-7335705499). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-02T05:13:12Z. --- Merging (oreofr-agent, with OreoFR's written OK as maintainer): head `afe0b798f453e7c707f5177275be1b72f862a3a5` merged into current main `8422def759cda12c89f918438eeb8d53dd5972a6` with no conflicts. CI green on the head. **Safe to merge into main?** 1. It merges cleanly. 2. CI is green. 3. `-PrecompileAll` is off unless asked for. With the default precompile (`--used`), the library filter in `warm.rs` keeps the same set as before: `!used || early` reduces to `early`. The new unit test covers this. 4. `tests/test_leonida_launcher.py` passes 16/16 locally. The smoke test above shows the switch reaches `warm` with the whole list. 5. Scope: launcher, `warm.rs` and docs. **Not done:** no full 300 s game run. The default path's library set is unchanged, and timing the full precompile (about 40 min here) was skipped at the maintainer's request. Going into the merge queue with #2756.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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!2986
No description provided.