d3d12: discard stale pipeline libraries across driver updates and self-heal refused entries (D3D12-PIPELINE-LIBRARY-DRIVER-STAMP) #2789

Open
zmasi wants to merge 12 commits from upstream-pr/2789 into main
zmasi commented 2026-11-30 21:08:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-30T21:08:42Z.


Summary

Fixes #2781 (D3D12-PIPELINE-LIBRARY-DRIVER-STAMP).

Across NVIDIA driver updates (616.64 -> 621.01), ID3D12Device1::CreatePipelineLibrary can accept the outer host-pipelines.bin container at startup while LoadGraphicsPipeline / LoadComputePipeline / LoadPipeline subsequently reject every stored blob with E_INVALIDARG (0x80070057). When pipeline() recompiled each refused PSO (410–5,228 ms per hitch) and called StorePipeline(name, &pso), StorePipeline also failed with E_INVALIDARG because an ID3D12PipelineLibrary cannot overwrite an existing name — leaving added == 0 (or re-serializing the stale blobs back to disk) and keeping the mismatched driver's library alive until device removal (0x887A0005).

This change adds two defense-in-depth layers inside d3d12/crates/leonida-gpu/src/pipeline/library.rs, controlled by LEONIDA_LIBRARY_DRIVER_CHECK (on by default; LEONIDA_LIBRARY_DRIVER_CHECK=0 restores the previous behavior):

  1. Proactive adapter & driver stamp sidecar (host-pipelines.driver):

    • Records a single-line adapter + UMD driver stamp (vendor, device, subsys, rev from DXGI_ADAPTER_DESC1 plus Host::driver() when driver != 0) alongside host-pipelines.bin.
    • At open_in(), if host-pipelines.driver names a different adapter or driver, host-pipelines.next, host-pipelines.bin, and host-pipelines.driver are discarded upfront before CreatePipelineLibrary is called, and an empty library is started cleanly.
    • Pre-existing unstamped caches load normally without an upfront wipe and backfill <stamp> older=1 on save until replaced, preserving Origin::doubtful() for Layer 2.
  2. Reactive self-healing swap (Library::keep / stale / begin_anew):

    • Places active library state behind RwLock<Active> (keeping saving separate so Serialize never blocks loads).
    • When a file-backed library without this driver's own plain stamp refuses Load*Pipeline on generation g, create() succeeds, StorePipeline(name, &pso) fails with E_INVALIDARG on the same generation g without name having been stored in this run (Seen::stored, guarded under same_name(name)), and a fresh empty library accepts pso, begin_anew() atomically swaps in the fresh library, replays non-title static-sampler probe pipelines (Seen::beside for pipeline::places), retains any mapped Blob in Library::retired (releasing its working-set pages via VirtualUnlock so trim() and removal_note() never see an unmapped view), and marks the library dirty (anew) so save replaces host-pipelines.bin and writes this driver's plain stamp.
    • Also passes a real null pointer (std::ptr::null()) to CreatePipelineLibrary when bytes.is_empty() (avoiding Rust's dangling 0x1 empty-slice pointer on VKD3D-Proton), uses unique staging filenames on save, and removes any stale host-pipelines.next when an in-place rename succeeds.

Verification

Tested on Windows 11 (10.0.26200), NVIDIA GeForce RTX 3090 (driver 610.88, UMD 32.0.16.1088), and D3D12 WARP (0x1414):

  • Red -> Green & concurrency unit/GPU tests (16 tests in pipeline::library::tests, 47 passed across pipeline::):
    • with_the_check_off_a_refused_pipeline_is_made_in_every_run (reproduces repeated 0x80070057 on both LoadComputePipeline and StorePipeline, added == 0, unchanged file across restarts when LEONIDA_LIBRARY_DRIVER_CHECK=0).
    • a_pipeline_neither_loaded_nor_replaced_begins_the_library_anew (verifies swap + 0.005–0.015 ms subsequent loads across both mapped and held blobs).
    • a_library_of_another_driver_is_not_handed_to_the_host and a_library_of_another_driver_that_cannot_be_deleted_is_not_called_this_drivers.
    • a_name_stored_in_this_run_does_not_begin_the_library_anew (4-thread barrier benign-race test), threads_that_find_it_out_together_begin_the_library_anew_once (8-thread single-swap race test), and pipelines_kept_beside_the_titles_go_into_the_library_begun_anew (places probe carry-over).
  • cargo clippy -p leonida-gpu --all-targets --locked and --features diagnostics --all-targets --locked: 0 warnings in library.rs; single touched file (host.rs and make.rs untouched).
  • python -I tests/test_d3d12_switches.py (19/19 passed) and python -I scripts/check_no_game_data.py (rc=0).

AI-assisted: authored with Claude Fable 5.2, independently reviewed with Gemini 4 Neon (XHigh), and verified with Gemini 4 Carbon (High).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5573790418 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-30T21:08:42Z. --- ## Summary Fixes #2781 (`D3D12-PIPELINE-LIBRARY-DRIVER-STAMP`). Across NVIDIA driver updates (`616.64 -> 621.01`), `ID3D12Device1::CreatePipelineLibrary` can accept the outer `host-pipelines.bin` container at startup while `LoadGraphicsPipeline` / `LoadComputePipeline` / `LoadPipeline` subsequently reject every stored blob with `E_INVALIDARG` (`0x80070057`). When `pipeline()` recompiled each refused PSO (`410–5,228 ms` per hitch) and called `StorePipeline(name, &pso)`, `StorePipeline` also failed with `E_INVALIDARG` because an `ID3D12PipelineLibrary` cannot overwrite an existing name — leaving `added == 0` (or re-serializing the stale blobs back to disk) and keeping the mismatched driver's library alive until device removal (`0x887A0005`). This change adds two defense-in-depth layers inside `d3d12/crates/leonida-gpu/src/pipeline/library.rs`, controlled by `LEONIDA_LIBRARY_DRIVER_CHECK` (on by default; `LEONIDA_LIBRARY_DRIVER_CHECK=0` restores the previous behavior): 1. **Proactive adapter & driver stamp sidecar (`host-pipelines.driver`)**: - Records a single-line adapter + UMD driver stamp (`vendor`, `device`, `subsys`, `rev` from `DXGI_ADAPTER_DESC1` plus `Host::driver()` when `driver != 0`) alongside `host-pipelines.bin`. - At `open_in()`, if `host-pipelines.driver` names a different adapter or driver, `host-pipelines.next`, `host-pipelines.bin`, and `host-pipelines.driver` are discarded upfront before `CreatePipelineLibrary` is called, and an empty library is started cleanly. - Pre-existing unstamped caches load normally without an upfront wipe and backfill `<stamp> older=1` on save until replaced, preserving `Origin::doubtful()` for Layer 2. 2. **Reactive self-healing swap (`Library::keep` / `stale` / `begin_anew`)**: - Places active library state behind `RwLock<Active>` (keeping `saving` separate so `Serialize` never blocks loads). - When a file-backed library without this driver's own plain stamp refuses `Load*Pipeline` on generation `g`, `create()` succeeds, `StorePipeline(name, &pso)` fails with `E_INVALIDARG` on the same generation `g` without `name` having been stored in this run (`Seen::stored`, guarded under `same_name(name)`), and a fresh empty library accepts `pso`, `begin_anew()` atomically swaps in the fresh library, replays non-title static-sampler probe pipelines (`Seen::beside` for `pipeline::places`), retains any mapped `Blob` in `Library::retired` (releasing its working-set pages via `VirtualUnlock` so `trim()` and `removal_note()` never see an unmapped view), and marks the library dirty (`anew`) so `save` replaces `host-pipelines.bin` and writes this driver's plain stamp. - Also passes a real null pointer (`std::ptr::null()`) to `CreatePipelineLibrary` when `bytes.is_empty()` (avoiding Rust's dangling `0x1` empty-slice pointer on VKD3D-Proton), uses unique staging filenames on save, and removes any stale `host-pipelines.next` when an in-place rename succeeds. ## Verification Tested on Windows 11 (`10.0.26200`), NVIDIA GeForce RTX 3090 (driver `610.88`, UMD `32.0.16.1088`), and D3D12 WARP (`0x1414`): - **Red -> Green & concurrency unit/GPU tests** (`16` tests in `pipeline::library::tests`, `47` passed across `pipeline::`): - `with_the_check_off_a_refused_pipeline_is_made_in_every_run` (reproduces repeated `0x80070057` on both `LoadComputePipeline` and `StorePipeline`, `added == 0`, unchanged file across restarts when `LEONIDA_LIBRARY_DRIVER_CHECK=0`). - `a_pipeline_neither_loaded_nor_replaced_begins_the_library_anew` (verifies swap + `0.005–0.015 ms` subsequent loads across both mapped and held blobs). - `a_library_of_another_driver_is_not_handed_to_the_host` and `a_library_of_another_driver_that_cannot_be_deleted_is_not_called_this_drivers`. - `a_name_stored_in_this_run_does_not_begin_the_library_anew` (4-thread barrier benign-race test), `threads_that_find_it_out_together_begin_the_library_anew_once` (8-thread single-swap race test), and `pipelines_kept_beside_the_titles_go_into_the_library_begun_anew` (`places` probe carry-over). - `cargo clippy -p leonida-gpu --all-targets --locked` and `--features diagnostics --all-targets --locked`: `0` warnings in `library.rs`; single touched file (`host.rs` and `make.rs` untouched). - `python -I tests/test_d3d12_switches.py` (`19/19` passed) and `python -I scripts/check_no_game_data.py` (`rc=0`). AI-assisted: authored with Claude Fable 5.2, independently reviewed with Gemini 4 Neon (XHigh), and verified with Gemini 4 Carbon (High).
KelboLive commented 2026-12-01 04:47:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T04:47:30Z.

Review: COMMENTED


Verified here on the machine that has the problem: NVIDIA 0x2705 with the driver line captured, cargo test -p leonida-gpu --lib pipeline:: -> 47 passed, 7 ignored (16 new library tests, and the GPU ones really ran — one prints "loaded from the library begun anew in 0.009 ms"), tests/test_d3d12_switches.py 19 OK with the switch read as "on, 0 turns it off".

The mechanism does what it says for a pre-sidecar cache: stamp_of (library.rs:928) writes vendor/device/subsys/rev plus Host::driver() (host.rs:1373), open_in (:990) classifies it, a mismatch discards the pair through discard (:948), and on a refusal that also loses the store, stale() + begin_anew (:749, :767) swap in an empty library and save writes a clean file under this driver's stamp. Nothing refused is ever written back: serialisation only ever uses active.library.

Two notes.

  1. Say in the body that the first run after a poisoned cache still looks poisoned. A missing name is also E_INVALIDARG on this device (the tests assert that after a swap), so the first run still logs made … did not load it: 0x80070057 for nearly every pipeline and still compiles all of them; the second run is the healed one. Otherwise testers (this machine included) will read the first run as the fix not working.
  2. A real bug: replace_library treats a failed removal of host-pipelines.next as success (library.rs:1302-1308). If NEXT is held by something else — a case discard already documents — the rename succeeds, the removal fails silently, and note(dir, &active, true) (:1246) writes this driver's plain stamp (:877-884). The next start then trusts the line, Blob::of (:263) renames the surviving other-driver NEXT over the library, the file loads as Origin::Noted, and stale() never heals it. Reproduced with NEXT held share_mode(0): after the save the line names this driver while NEXT still exists, and the next run stays (0, Noted) after a refusal. Only write the plain stamp when NEXT is actually gone (or adopt NEXT before comparing the sidecar).
<!-- greyfinch-sync:ubiquitarianism/leonida:review:6125283422 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#pullrequestreview-6125283422). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T04:47:30Z. **Review:** COMMENTED --- Verified here on the machine that has the problem: NVIDIA `0x2705` with the driver line captured, `cargo test -p leonida-gpu --lib pipeline::` -> **47 passed**, 7 ignored (16 new library tests, and the GPU ones really ran — one prints "loaded from the library begun anew in 0.009 ms"), `tests/test_d3d12_switches.py` 19 OK with the switch read as "on, `0` turns it off". The mechanism does what it says for a pre-sidecar cache: `stamp_of` (`library.rs:928`) writes vendor/device/subsys/rev plus `Host::driver()` (`host.rs:1373`), `open_in` (`:990`) classifies it, a mismatch discards the pair through `discard` (`:948`), and on a refusal that also loses the store, `stale()` + `begin_anew` (`:749`, `:767`) swap in an empty library and `save` writes a clean file under this driver's stamp. Nothing refused is ever written back: serialisation only ever uses `active.library`. Two notes. 1. **Say in the body that the first run after a poisoned cache still looks poisoned.** A *missing* name is also `E_INVALIDARG` on this device (the tests assert that after a swap), so the first run still logs `made … did not load it: 0x80070057` for nearly every pipeline and still compiles all of them; the second run is the healed one. Otherwise testers (this machine included) will read the first run as the fix not working. 2. **A real bug:** `replace_library` treats a failed removal of `host-pipelines.next` as success (`library.rs:1302-1308`). If NEXT is held by something else — a case `discard` already documents — the rename succeeds, the removal fails silently, and `note(dir, &active, true)` (`:1246`) writes this driver's **plain** stamp (`:877-884`). The next start then trusts the line, `Blob::of` (`:263`) renames the surviving other-driver NEXT over the library, the file loads as `Origin::Noted`, and `stale()` never heals it. Reproduced with NEXT held `share_mode(0)`: after the save the line names this driver while NEXT still exists, and the next run stays `(0, Noted)` after a refusal. Only write the plain stamp when NEXT is actually gone (or adopt NEXT before comparing the sidecar).
Kal0s-design commented 2026-12-01 06:13:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-01T06:13:43Z.


Independent Windows check of e38238383 on current main 640b0d0df (no conflict, merge 5ec44016e). Native Windows 11, MSVC x64, Rust 1.98.1, with a hardware D3D12 device, so the library tests that make real pipelines through Card (host().device → ID3D12Device1) ran rather than skipped.

  • cargo test -p leonida-gpu --lib: 609 passed, 0 failed, 54 ignored. main lists 653 tests, the merge 663, so the 10 new pipeline::library tests are the only addition.
  • The 16 pipeline::library tests, the new ones included, run 200 times on their own in the release build with 16 test threads: 0 failures. That covers threads_that_find_it_out_together_begin_the_library_anew_once, a_library_of_another_driver_is_not_handed_to_the_host and concurrent_write_atomically_never_fails_or_truncates.
  • Not covered: an actual driver update between two runs (the stamp change is simulated by the tests).

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7302633824 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7302633824). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-01T06:13:43Z. --- **Independent Windows check** of `e38238383` on current `main` `640b0d0df` (no conflict, merge `5ec44016e`). Native Windows 11, MSVC x64, Rust 1.98.1, with a hardware D3D12 device, so the library tests that make real pipelines through `Card` (`host().device` → `ID3D12Device1`) ran rather than skipped. - `cargo test -p leonida-gpu --lib`: 609 passed, 0 failed, 54 ignored. `main` lists 653 tests, the merge 663, so the 10 new `pipeline::library` tests are the only addition. - The 16 `pipeline::library` tests, the new ones included, run 200 times on their own in the release build with 16 test threads: 0 failures. That covers `threads_that_find_it_out_together_begin_the_library_anew_once`, `a_library_of_another_driver_is_not_handed_to_the_host` and `concurrent_write_atomically_never_fails_or_truncates`. - Not covered: an actual driver update between two runs (the stamp change is simulated by the tests). AI-assisted: yes
Neutron-0 commented 2026-12-01 10:20:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-01T10:20:26Z.


A heads-up for this pull request: the page of D3D12 switches (d3d12/docs/switches.md) is written by tools/d3d12_switches.py from the sources of d3d12/, and 1 name this pull request reads is not on the page yet: LEONIDA_LIBRARY_DRIVER_CHECK.

Nothing checks that today, so the page has drifted before (it was a name behind when this was measured). A test that checks it is waiting to be opened (DOCS-SWITCHES-PAGE-CHECK), and it would make this pull request's CI red until the page is written again. One command does that:

python -I tools/d3d12_switches.py --out d3d12/docs/switches.md

It writes the page with the names in it and nothing else; the diff is the new rows.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7308037489 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7308037489). Originally posted by [Neutron-0](https://github.com/Neutron-0) on 2026-12-01T10:20:26Z. --- A heads-up for this pull request: the page of D3D12 switches (`d3d12/docs/switches.md`) is written by `tools/d3d12_switches.py` from the sources of `d3d12/`, and 1 name this pull request reads is not on the page yet: `LEONIDA_LIBRARY_DRIVER_CHECK`. Nothing checks that today, so the page has drifted before (it was a name behind when this was measured). A test that checks it is waiting to be opened (DOCS-SWITCHES-PAGE-CHECK), and it would make this pull request's CI red until the page is written again. One command does that: ``` python -I tools/d3d12_switches.py --out d3d12/docs/switches.md ``` It writes the page with the names in it and nothing else; the diff is the new rows.
zmasi commented 2026-12-01 10:58:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-01T10:58:11Z.


Thanks for the heads-up @Neutron-0 — regenerated d3d12/docs/switches.md (LEONIDA_LIBRARY_DRIVER_CHECK, --check rc 0) in 573f7f216.

AI-assisted: Gemini 4 Carbon.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7308983097 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7308983097). Originally posted by [zmasi](https://github.com/zmasi) on 2026-12-01T10:58:11Z. --- Thanks for the heads-up @Neutron-0 — regenerated `d3d12/docs/switches.md` (`LEONIDA_LIBRARY_DRIVER_CHECK`, `--check` rc 0) in `573f7f216`. AI-assisted: Gemini 4 Carbon.
merzleckeier commented 2026-12-01 12:17:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T12:17:19Z.


Independent check of 573f7f216 on c60ce461a. All 16 pipeline-library tests completed on both GPUs, using the Windows MSVC test binary under Wine and vkd3d-proton 3.1.0 with VKD3D_CONFIG=pipeline_library_app_cache. GPUs were AMD Raphael (RADV 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.4).

The test cases cover a differing driver note, refusal of a cached compute pipeline with the check off, saving and then reloading a rebuilt entry with the check on, and concurrent detection rebuilding the library only once. The revisions to the library state were synthetic. A native Windows driver upgrade was outside the run.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310918739 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7310918739). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T12:17:19Z. --- Independent check of `573f7f216` on `c60ce461a`. All 16 pipeline-library tests completed on both GPUs, using the Windows MSVC test binary under Wine and vkd3d-proton 3.1.0 with `VKD3D_CONFIG=pipeline_library_app_cache`. GPUs were AMD Raphael (RADV 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.4). The test cases cover a differing driver note, refusal of a cached compute pipeline with the check off, saving and then reloading a rebuilt entry with the check on, and concurrent detection rebuilding the library only once. The revisions to the library state were synthetic. A native Windows driver upgrade was outside the run. AI-assisted with OpenAI Codex.
lixonik commented 2026-12-01 21:49:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T21:49:16Z.


Independent check of c44b20fec merged cleanly on main (1e3e316c5), on native Windows 10 Pro 22H2 (build 19045) + NVIDIA GeForce RTX 5070 12 GB (driver 621.40, Ryzen 9 5950X):

  • cargo test --locked -p leonida-gpu --lib pipeline::library -- --nocapture: 16 passed, 0 failed (live GPU self-heal tests ran on RTX 5070 / 621.40, printing loaded from the library begun anew in 0.009 ms and 0.008 ms).
  • cargo test --locked -p leonida-gpu --lib pipeline:: -- --skip depth_bounds_pipeline_loads_and_filters_draws: 47 passed, 0 failed, 8 ignored (depth_bounds_pipeline_loads_and_filters_draws skipped for the separate Win10 inbox d3d12.dll SM 6.6 flag issue tracked in #2855).
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0; test_d3d12_switches.py: 19 passed, 0 failed.
  • Zero new compiler warnings in pipeline/library.rs.

AI-assisted: Antigravity

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7326834815 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7326834815). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-01T21:49:16Z. --- Independent check of `c44b20fec` merged cleanly on `main` (`1e3e316c5`), on native Windows 10 Pro 22H2 (build 19045) + NVIDIA GeForce RTX 5070 12 GB (driver `621.40`, Ryzen 9 5950X): - `cargo test --locked -p leonida-gpu --lib pipeline::library -- --nocapture`: **16 passed, 0 failed** (live GPU self-heal tests ran on RTX 5070 / `621.40`, printing `loaded from the library begun anew in 0.009 ms` and `0.008 ms`). - `cargo test --locked -p leonida-gpu --lib pipeline:: -- --skip depth_bounds_pipeline_loads_and_filters_draws`: **47 passed, 0 failed, 8 ignored** (`depth_bounds_pipeline_loads_and_filters_draws` skipped for the separate Win10 inbox `d3d12.dll` SM 6.6 flag issue tracked in #2855). - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`: exit `0`; `test_d3d12_switches.py`: **19 passed, 0 failed**. - Zero new compiler warnings in `pipeline/library.rs`. AI-assisted: Antigravity
fiestorra commented 2026-12-01 22:31:31 +00:00 (Migrated from github.com)

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


Independent verification on an RTX 4090, driver 621.24 (32.0.16.2124), Windows 11 - by the method in AGENTS.md (PR ref, merge-tree, apply it on main, run what it touches).

Applied on main 1fff69129:

git merge-tree --write-tree origin/main refs/remotes/pr/2789     no conflicts
git merge --squash refs/remotes/pr/2789                          clean, 2 files

One thing worth knowing: a commit-by-commit cherry-pick of the range (3dd1bf42..c44b20fec, 8 commits) does conflict in pipeline/library.rs - main moved under it. The squash-merge is clean, so merging is fine; a rebase would be needed only if the branch is to be kept linear.

What it does here:

cargo test -p leonida-gpu --lib -- --test-threads=1 pipeline::library
    ok. 16 passed; 0 failed

cargo test -p leonida-gpu --lib -- --test-threads=1
    653 passed; 1 failed; 59 ignored
    the one that fails is descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in,
    which fails the same way on main without this change (reported in #2570; it is the byte
    comparison, not the copy)

cargo clippy -p leonida-gpu --all-targets
    1 warning: unused mut at host.rs:7628 - also there on main, not yours (#2877 carries the fix)

python -I tests/test_d3d12_switches.py
    passed (exit 0), so LEONIDA_LIBRARY_DRIVER_CHECK is documented as the code reads it

What I could not test, and would not claim: the case the issue is about - a library written under one driver and opened under another. Downgrading this machine's driver is not something I will do to a working setup, so the 616.64 -> 621.01 transition is verified only through your own tests (a_library_of_another_driver_is_not_handed_to_the_host and the two that begin the library anew), which is a fake stamp, not a driver that changed. And the title was not run with it.

What that leaves as risk: the stamp is read from DXGI_ADAPTER_DESC1, and the case that matters is a driver update that keeps the same device id and changes only the UMD version - if the driver applies its version elsewhere than the fields you read, the stamp would not move and the library would still be handed over. Worth one line in the PR saying which fields change on an update, since the person who can check it is someone who upgraded and kept the old file.

AI-assisted: yes - DeepSeek v4.1 (flash).

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7327976368 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7327976368). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-01T22:31:31Z. --- **Independent verification on an RTX 4090, driver 621.24 (32.0.16.2124), Windows 11 - by the method in `AGENTS.md` (PR ref, merge-tree, apply it on `main`, run what it touches).** **Applied on `main` `1fff69129`:** ``` git merge-tree --write-tree origin/main refs/remotes/pr/2789 no conflicts git merge --squash refs/remotes/pr/2789 clean, 2 files ``` **One thing worth knowing**: a **commit-by-commit** cherry-pick of the range (`3dd1bf42..c44b20fec`, 8 commits) **does conflict** in `pipeline/library.rs` - `main` moved under it. The squash-merge is clean, so merging is fine; a rebase would be needed only if the branch is to be kept linear. **What it does here:** ``` cargo test -p leonida-gpu --lib -- --test-threads=1 pipeline::library ok. 16 passed; 0 failed cargo test -p leonida-gpu --lib -- --test-threads=1 653 passed; 1 failed; 59 ignored the one that fails is descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in, which fails the same way on main without this change (reported in #2570; it is the byte comparison, not the copy) cargo clippy -p leonida-gpu --all-targets 1 warning: unused mut at host.rs:7628 - also there on main, not yours (#2877 carries the fix) python -I tests/test_d3d12_switches.py passed (exit 0), so LEONIDA_LIBRARY_DRIVER_CHECK is documented as the code reads it ``` **What I could not test, and would not claim:** **the case the issue is about - a library written under one driver and opened under another.** **Downgrading this machine's driver is not something I will do to a working setup**, so the 616.64 -> 621.01 transition is verified only through your own tests (`a_library_of_another_driver_is_not_handed_to_the_host` and the two that begin the library anew), **which is a fake stamp, not a driver that changed.** **And the title was not run with it.** **What that leaves as risk**: **the stamp is read from `DXGI_ADAPTER_DESC1`, and the case that matters is a driver update that keeps the same device id and changes only the UMD version** - **if the driver applies its version elsewhere than the fields you read, the stamp would not move and the library would still be handed over.** **Worth one line in the PR saying which fields change on an update**, since the person who can check it is someone who upgraded and kept the old file. **AI-assisted:** yes - DeepSeek v4.1 (flash). Written with an AI assistant.
andrew-ai commented 2026-12-02 00:26:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-02T00:26:47Z.


At 4cec236e4 I queried the production stamp(host) in three fresh Windows processes using one diagnostics build. The RTX 5070 returned vendor 0x10de, device 0x2f04, driver 9007199255791260. WARP returned vendor 0x1414, device 0x008c, driver 2814751477606228. Returning to the 5070 reproduced the complete first stamp byte for byte.

I then exercised both on-disk mismatch tests on the 5070, substituting that measured WARP stamp in the test sidecar. With the check enabled, the ordinary case discarded the stale library, saved a rebuilt pipeline under the current stamp and loaded it on reopen. With an exclusive handle on the stale library file, the save could not replace it. The file was not relabeled as current, and reopening started with an empty library. Both tests reached the readback assertions; I added temporary test-only output to distinguish that from an early return.

These are real D3D12 pipeline files in temporary directories, with deliberately mismatched metadata. No driver installation was changed. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7330556504 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7330556504). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-02T00:26:47Z. --- At 4cec236e4 I queried the production stamp(host) in three fresh Windows processes using one diagnostics build. The RTX 5070 returned vendor 0x10de, device 0x2f04, driver 9007199255791260. WARP returned vendor 0x1414, device 0x008c, driver 2814751477606228. Returning to the 5070 reproduced the complete first stamp byte for byte. I then exercised both on-disk mismatch tests on the 5070, substituting that measured WARP stamp in the test sidecar. With the check enabled, the ordinary case discarded the stale library, saved a rebuilt pipeline under the current stamp and loaded it on reopen. With an exclusive handle on the stale library file, the save could not replace it. The file was not relabeled as current, and reopening started with an empty library. Both tests reached the readback assertions; I added temporary test-only output to distinguish that from an early return. These are real D3D12 pipeline files in temporary directories, with deliberately mismatched metadata. No driver installation was changed. Codex-assisted.
MoonEyes commented 2026-12-02 12:25:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:25:17Z.


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:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345312476 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7345312476). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:25:17Z. --- 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`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone 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).
ninjalegxd commented 2026-12-02 14:53:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ninjalegxd on 2026-12-02T14:53:41Z.


Tested this PR on RTX 3090, driver 621.14 (32.0.16.2114), Win11, -SeriesS -NoFrameGen:

  • host-pipelines.bin loaded as pipelines=Older (unstamped)
  • 35 x "the library did not load it ... (0x80070057)" during the run
  • device removed (0x887A0005) after ~5 min, "device-removed data; none"
  • no "begin anew" / swap in the log

Important: this library was created fresh last night by the SAME driver (621.14),
after I had moved the previous one aside. So on this machine the blobs are refused
without any driver change; the stamp alone can't catch it, and the self-heal swap
did not trigger either.
Log attached.

play-1202-164536.log

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7349319978 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7349319978). Originally posted by [ninjalegxd](https://github.com/ninjalegxd) on 2026-12-02T14:53:41Z. --- Tested this PR on RTX 3090, driver 621.14 (32.0.16.2114), Win11, -SeriesS -NoFrameGen: - host-pipelines.bin loaded as `pipelines=Older` (unstamped) - 35 x "the library did not load it ... (0x80070057)" during the run - device removed (0x887A0005) after ~5 min, "device-removed data; none" - no "begin anew" / swap in the log Important: this library was created fresh last night by the SAME driver (621.14), after I had moved the previous one aside. So on this machine the blobs are refused without any driver change; the stamp alone can't catch it, and the self-heal swap did not trigger either. Log attached. [play-1202-164536.log](https://github.com/user-attachments/files/35749087/play-1202-164536.log)
ninjalegxd commented 2026-12-02 14:55:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ninjalegxd on 2026-12-02T14:55:59Z.


Head tested: 4bd128a8c7.
Numbers for comparison, same PC / save / area, -SeriesS:

Build Runs Device lost Time to loss Median fps (world)
main (2705632c5 and before) 4 4 3-5.5 min ~22-29
main, after moving host-pipelines.bin aside 1 1 ~20 min ~28
this PR (4bd128a8c7) 1 1 ~5 min 21.8

On main, 2 of the 4 runs had -FsrFrameGen and 2 had -NoFrameGen; all lost the device.
The PR run was -NoFrameGen.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7349389678 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7349389678). Originally posted by [ninjalegxd](https://github.com/ninjalegxd) on 2026-12-02T14:55:59Z. --- Head tested: 4bd128a8c7. Numbers for comparison, same PC / save / area, -SeriesS: | Build | Runs | Device lost | Time to loss | Median fps (world) | |---|---|---|---|---| | main (2705632c5 and before) | 4 | 4 | 3-5.5 min | ~22-29 | | main, after moving host-pipelines.bin aside | 1 | 1 | ~20 min | ~28 | | this PR (4bd128a8c7) | 1 | 1 | ~5 min | 21.8 | On main, 2 of the 4 runs had -FsrFrameGen and 2 had -NoFrameGen; all lost the device. The PR run was -NoFrameGen.
merzleckeier commented 2026-12-02 15:11:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T15:11:51Z.

Review: COMMENTED


On 4bd128a8 merged onto 83046a71, all 16 library tests reported pass on both Radeon RADV and RTX 4070 SUPER (Wine 11.22 / VKD3D-Proton). I also ran a local probe that required a real D3D12 device and supplied a synthetic same-driver stamp, so the provenance cases could not skip for missing driver metadata.

On both GPUs, four free-name LoadComputePipeline calls each returned E_INVALIDARG, but the newly compiled pipelines stored successfully and the library stayed in generation 0. Changing the descriptor of an existing name produced the same load HRESULT and a duplicate-name store refusal. With older=1, that triggered the replacement and the rebuilt entry loaded successfully. The replacement no longer held any of the four fresh entries stored earlier in that run. With a plain current stamp, no replacement happened and all four remained.

The load HRESULT count alone therefore cannot show why the reported run did not swap. Recording the store result and origin on the refusal path would help distinguish these cases. This probe uses synthetic pipelines and does not establish a cause for the reported device loss. Reported run

The head merges cleanly on 83046a71. Pairwise merge-tree checks with #2654 and #3150 each reported a conflict in pipeline/library.rs. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6153573953 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#pullrequestreview-6153573953). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T15:11:51Z. **Review:** COMMENTED --- On `4bd128a8` merged onto `83046a71`, all 16 library tests reported pass on both Radeon RADV and RTX 4070 SUPER (Wine 11.22 / VKD3D-Proton). I also ran a local probe that required a real D3D12 device and supplied a synthetic same-driver stamp, so the provenance cases could not skip for missing driver metadata. On both GPUs, four free-name `LoadComputePipeline` calls each returned `E_INVALIDARG`, but the newly compiled pipelines stored successfully and the library stayed in generation 0. Changing the descriptor of an existing name produced the same load HRESULT and a duplicate-name store refusal. With `older=1`, that triggered the replacement and the rebuilt entry loaded successfully. The replacement no longer held any of the four fresh entries stored earlier in that run. With a plain current stamp, no replacement happened and all four remained. The load HRESULT count alone therefore cannot show why the reported run did not swap. Recording the store result and origin on the refusal path would help distinguish these cases. This probe uses synthetic pipelines and does not establish a cause for the reported device loss. [Reported run](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7349319978) The head merges cleanly on `83046a71`. Pairwise merge-tree checks with #2654 and #3150 each reported a conflict in `pipeline/library.rs`. AI-assisted with OpenAI Codex.
fiestorra commented 2026-12-02 15:16:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T15:16:03Z.


Read the 3090 report against what this branch actually stamps, because it separates into two things that are not this change.

1. The head is right, the merge is not the requested one. 4bd128a8c7 is the current head, as the report says - but it was merged with a main that has since moved: the branch is 60 files behind origin/main right now (docs/lua-modding.md, scripts/play-linux.sh, tests/*), so a report on this head is not a report on "the current head merged onto current main". A fresh merge + a re-run is what @MoonEyes asked for, and it is cheap.

2. The device removal is not this change. device removed (0x887A0005) after ~5 min is #3068's exact shape ("after 7–18 min of play, right after a masked-twin ..."), and it happened on main before this branch existed. Whatever the library does, that will still be there, so the two should not be read together.

3. The 35 loads that failed are the interesting part, and the stamp does not explain them. What the note records is "one line that names the adapter and driver" (library.rs:584-586), and older=1 marks a library taken over from before the check existed. A library made by another build of the layer on the same card and driver passes that check and is loaded, and the reporter says this one was "created fresh last night by the SAME driver" - so a library from a different build of the layer is exactly the case the stamp cannot see.

But it is not simply "another build" either: on this machine (RTX 4090, driver 621.24) a library written by one build loads in another - 540 of 540 in the pipeline library, written in 21 s in a leonida warm run against last night's cache. So the build is a variable, not the whole story, and 0x80070057 (E_INVALIDARG out of LoadPipeline) says those particular blobs were refused rather than the library being from elsewhere.

What would settle it, in that log:

  • the contents of host-pipelines.driver next to host-pipelines.bin - it names the adapter and driver, so it says whether the check thought the library was its own;
  • one full the library did not load it ... (0x80070057) line with its pipeline name, and whether the same pipelines were made again in that run (they would appear in the warm/first bind lines);
  • and the layer's build that wrote the library against the one that read it, which the stamp cannot tell - that is the gap I would close in this branch: put the layer's own hash in the note, the way the shader cache already keys itself.

AI-assisted: yes - DeepSeek v4.1 (flash).

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7350032985 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7350032985). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T15:16:03Z. --- **Read the 3090 report against what this branch actually stamps, because it separates into two things that are not this change.** **1. The head is right, the merge is not the requested one.** `4bd128a8c7` is the current head, as the report says - **but it was merged with a `main` that has since moved**: the branch is 60 files behind `origin/main` right now (`docs/lua-modding.md`, `scripts/play-linux.sh`, `tests/*`), so **a report on this head is not a report on "the current head merged onto current main"**. A fresh merge + a re-run is what @MoonEyes asked for, and it is cheap. **2. The device removal is not this change.** `device removed (0x887A0005) after ~5 min` is **#3068's** exact shape ("after 7–18 min of play, right after a masked-twin ..."), and it happened on `main` before this branch existed. **Whatever the library does, that will still be there**, so the two should not be read together. **3. The 35 loads that failed are the interesting part, and the stamp does not explain them.** What the note records is **"one line that names the adapter and driver"** (`library.rs:584-586`), and `older=1` marks a library taken over from before the check existed. **A library made by another build of the layer on the same card and driver passes that check and is loaded**, and the reporter says this one was **"created fresh last night by the SAME driver"** - so a library from a **different build** of the layer is exactly the case the stamp cannot see. **But it is not simply "another build" either**: on this machine (RTX 4090, driver 621.24) a library written by **one build** loads in **another** - `540 of 540 in the pipeline library, written in 21 s` in a `leonida warm` run against last night's cache. **So the build is a variable, not the whole story**, and `0x80070057` (`E_INVALIDARG` out of `LoadPipeline`) says those particular blobs were refused rather than the library being from elsewhere. **What would settle it**, in that log: - **the contents of `host-pipelines.driver`** next to `host-pipelines.bin` - it names the adapter and driver, so it says whether the check thought the library was its own; - **one full `the library did not load it ... (0x80070057)` line with its pipeline name**, and whether the same pipelines were made again in that run (they would appear in the `warm`/`first bind` lines); - **and the layer's build that wrote the library** against the one that read it, which the stamp cannot tell - **that is the gap I would close in this branch**: put the layer's own hash in the note, the way the shader cache already keys itself. **AI-assisted:** yes - DeepSeek v4.1 (flash). Written with an AI assistant.
ninjalegxd commented 2026-12-02 15:21:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ninjalegxd on 2026-12-02T15:21:29Z.


Checked the log as asked: the refused loads are new pipelines, not stale blobs.

Example: [mesh 024bb426570bd221, pixel 1dc40c638c94c4b0] "did not load it (0x80070057)".
The same log shows shader translated stage="mesh" hash=024bb426570bd221 and its first bind
at 14:50:08, i.e. first time in that run. All 35 lines are in the dump printed at the removal
("ms before"), from the last ~30 s, after a burst of new pipelines in a new area.

host-pipelines.driver:
vendor=0x10de device=0x2204 subsys=0x40431458 rev=0xa1 driver=9007199255791682 older=1
(= 32.0.16.2114, the installed 621.14)

So the library looks fine here; my device loss matches #3068 rather than this PR.

AI-assisted: -Claude Opus 5.5 helped analyze the logs and draft all comments.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7350186365 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7350186365). Originally posted by [ninjalegxd](https://github.com/ninjalegxd) on 2026-12-02T15:21:29Z. --- Checked the log as asked: the refused loads are new pipelines, not stale blobs. Example: [mesh 024bb426570bd221, pixel 1dc40c638c94c4b0] "did not load it (0x80070057)". The same log shows `shader translated stage="mesh" hash=024bb426570bd221` and its first bind at 14:50:08, i.e. first time in that run. All 35 lines are in the dump printed at the removal ("ms before"), from the last ~30 s, after a burst of new pipelines in a new area. host-pipelines.driver: vendor=0x10de device=0x2204 subsys=0x40431458 rev=0xa1 driver=9007199255791682 older=1 (= 32.0.16.2114, the installed 621.14) So the library looks fine here; my device loss matches #3068 rather than this PR. AI-assisted: -Claude Opus 5.5 helped analyze the logs and draft all comments.
MoonEyes commented 2026-12-02 17:04:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T17:04:24Z.


RUN (independent run on Windows, #2789 head 4bd128a8c, merged locally into main 5b1fff821 with git merge --no-ff)

Machine: RTX 4060, driver 32.0.16.1088. Only leonida-gpu was built (release, --locked). The pipeline library tests make real pipelines on the card; they return early when there is no GPU, and here there is one.

Red (main's library.rs swapped back into the merged tree, same command: cargo test -p leonida-gpu --release --locked --lib -- pipeline::library)

  • 6 tests, 6 pass. The 10 tests the PR adds do not exist there, and main has no stamp at all: nothing in main notices a library of another driver. Main's own tests pass because they never exercise the driver change.
  • A red on behaviour comes from the mutations below, which put main's behaviour back piece by piece. Restored afterwards, git status clean.

Green (merged tree)

  • -- pipeline::library: 16 passed, 0 failed (the 6 of main plus 10 new, among them a_library_of_another_driver_is_not_handed_to_the_host, ..._that_cannot_be_deleted_is_not_called_this_drivers, a_library_this_driver_made_whole_is_not_begun_anew, the_line_beside_the_file_says_what_is_known_of_the_library, the_adapter_and_driver_are_named_on_one_line).
  • Whole leonida-gpu lib: 713 passed, 0 failed, 59 ignored (the ignored ones are measurements or marked so in the code).

Mutations (each one edit in pipeline/library.rs, then the 16 library tests)

  1. Stamp ignored on mismatch (if false && driver_check() in open_in): 2 fail (a_library_of_another_driver_is_not_handed_to_the_host, ..._that_cannot_be_deleted_...). Killed.
  2. Stamp not compared (any line counts as Noted): 4 fail. Killed.
  3. Old file kept (discard no longer deletes host-pipelines.bin): 2 fail. Killed.
  4. Wrong field (driver= written with the adapter revision): 1 fail, the_adapter_and_driver_are_named_on_one_line. Killed, but only by that pure test: the on-card tests build both sides with the same function, so they would not see it.
  5. Line never written after a save (Origin::Empty if replaced => return): 2 fail. Killed.
    5 of 5 killed.

Review

  • First launch after a driver change: the stamp in host-pipelines.driver differs from the current one, so discard deletes host-pipelines.next, then the library, then the line, and an empty library is begun in the same run. No crash, nothing handed to the host; every pipeline is compiled once and the first save writes a library and a line for the new driver. The test then reloads it and gets Origin::Noted with the pipeline loaded from the file.
  • A file that cannot be deleted (held open): the old library is not used and the line is not rewritten to claim it, so the next run does not trust a file that is still the old driver's. Tested.
  • Corrupt line: any text that is not the current stamp (or the stamp plus older=1) is read as another driver, so the library is discarded. The line is escaped and cut to 160 characters before it is logged. Non-UTF-8 bytes are read lossily, so they also mismatch.
  • Missing line, or the system gives no driver number: the library is used as before (Unnoted), so nothing changes for those. The old fallback then covers it: when a load is refused and the replacement cannot take the name, the library is begun anew once. This is the case of anyone who already has a stale file from before this PR; they are fixed on the first refusal, not at open.
  • Same driver: the line equals the stamp, the file is opened as before, a refusal in a library this driver made whole does not begin it anew (tested), and no line is rewritten. LEONIDA_LIBRARY_DRIVER_CHECK=0 returns to the old behaviour; it is in switches.md.
  • Small point, not blocking: the stamp includes the driver number from Host::driver(); I did not check it moves between two NVIDIA builds that share a version number (hotfix reinstall).

Not covered: no in-game run from me; the 3090 run is pending. Not run: the other crates, and the real driver-update path (the tests write an older line by hand; no second driver was installed).

Verdict: PASS on the tests and the review. Red is shown by mutation, not by main's own tests.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352861392 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7352861392). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T17:04:24Z. --- RUN (independent run on Windows, #2789 head `4bd128a8c`, merged locally into `main` `5b1fff821` with `git merge --no-ff`) Machine: RTX 4060, driver 32.0.16.1088. Only `leonida-gpu` was built (release, `--locked`). The pipeline library tests make real pipelines on the card; they return early when there is no GPU, and here there is one. **Red** (main's `library.rs` swapped back into the merged tree, same command: `cargo test -p leonida-gpu --release --locked --lib -- pipeline::library`) - 6 tests, 6 pass. The 10 tests the PR adds do not exist there, and main has no stamp at all: nothing in main notices a library of another driver. Main's own tests pass because they never exercise the driver change. - A red on behaviour comes from the mutations below, which put main's behaviour back piece by piece. Restored afterwards, `git status` clean. **Green** (merged tree) - `-- pipeline::library`: 16 passed, 0 failed (the 6 of main plus 10 new, among them `a_library_of_another_driver_is_not_handed_to_the_host`, `..._that_cannot_be_deleted_is_not_called_this_drivers`, `a_library_this_driver_made_whole_is_not_begun_anew`, `the_line_beside_the_file_says_what_is_known_of_the_library`, `the_adapter_and_driver_are_named_on_one_line`). - Whole `leonida-gpu` lib: 713 passed, 0 failed, 59 ignored (the ignored ones are measurements or marked so in the code). **Mutations** (each one edit in `pipeline/library.rs`, then the 16 library tests) 1. Stamp ignored on mismatch (`if false && driver_check()` in `open_in`): 2 fail (`a_library_of_another_driver_is_not_handed_to_the_host`, `..._that_cannot_be_deleted_...`). Killed. 2. Stamp not compared (any line counts as `Noted`): 4 fail. Killed. 3. Old file kept (`discard` no longer deletes `host-pipelines.bin`): 2 fail. Killed. 4. Wrong field (`driver=` written with the adapter revision): 1 fail, `the_adapter_and_driver_are_named_on_one_line`. Killed, but only by that pure test: the on-card tests build both sides with the same function, so they would not see it. 5. Line never written after a save (`Origin::Empty if replaced => return`): 2 fail. Killed. 5 of 5 killed. **Review** - First launch after a driver change: the stamp in `host-pipelines.driver` differs from the current one, so `discard` deletes `host-pipelines.next`, then the library, then the line, and an empty library is begun in the same run. No crash, nothing handed to the host; every pipeline is compiled once and the first save writes a library and a line for the new driver. The test then reloads it and gets `Origin::Noted` with the pipeline loaded from the file. - A file that cannot be deleted (held open): the old library is not used and the line is not rewritten to claim it, so the next run does not trust a file that is still the old driver's. Tested. - Corrupt line: any text that is not the current stamp (or the stamp plus ` older=1`) is read as another driver, so the library is discarded. The line is escaped and cut to 160 characters before it is logged. Non-UTF-8 bytes are read lossily, so they also mismatch. - Missing line, or the system gives no driver number: the library is used as before (`Unnoted`), so nothing changes for those. The old fallback then covers it: when a load is refused and the replacement cannot take the name, the library is begun anew once. This is the case of anyone who already has a stale file from before this PR; they are fixed on the first refusal, not at open. - Same driver: the line equals the stamp, the file is opened as before, a refusal in a library this driver made whole does not begin it anew (tested), and no line is rewritten. `LEONIDA_LIBRARY_DRIVER_CHECK=0` returns to the old behaviour; it is in `switches.md`. - Small point, not blocking: the stamp includes the driver number from `Host::driver()`; I did not check it moves between two NVIDIA builds that share a version number (hotfix reinstall). **Not covered**: no in-game run from me; the 3090 run is pending. Not run: the other crates, and the real driver-update path (the tests write an older line by hand; no second driver was installed). **Verdict**: PASS on the tests and the review. Red is shown by mutation, not by main's own tests. AI-assisted (Claude Code).
enlight3d commented 2026-12-02 17:07:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-02T17:07:49Z.


RUN (in game, gate-style, as asked by MoonEyes): head 4bd128a8c tested in a batch with #2643 (2cea6871c), #3031 (a47b86855), #2789 (4bd128a8c) and #2661 (1b3f3dee0), all merged with git merge --no-ff onto main 23a51c494 (no conflict; the only file the four share is d3d12/docs/switches.md). Built with diagnostics,mimalloc, target x86_64-pc-windows-msvc. RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro (build 26300).

Launcher defaults, Series S settings, -NoDlss -NoFrameGen, standing at the save; a warm-up run first (the batch changes the translator, so everything was re-translated), then one run of 420 s with the memory safety stop:

Reached the world 71 s
Time in the world 349 s
Device losses 0
Crashes 0
Frame median 29.4 ms (33.6 fps rendered)
Card busy 95 %
Private memory, max 26.6 GB

This pull request's own lines: host-pipelines.driver was written during the warm-up (stamp with the adapter and driver, older=1 as the change describes for a pre-existing library), the library then loaded (pipelines=Older) and saved with 2,330 pipelines loaded and 47 made, and no "the library did not load it" line appeared. No driver change was exercised here (the driver did not change between runs).

Verdict: PASS for the batch (a pass covers each of the four; a failure would not have said which). Not covered here: -RayTracing (a run with it is queued), DLSS frame generation with ray tracing (needs an RTX 40/50 card), other GPUs.

AI-assisted: Claude Code (Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352941075 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7352941075). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-02T17:07:49Z. --- RUN (in game, gate-style, as asked by MoonEyes): head 4bd128a8c tested **in a batch** with #2643 (2cea6871c), #3031 (a47b86855), #2789 (4bd128a8c) and #2661 (1b3f3dee0), all merged with `git merge --no-ff` onto `main` 23a51c494 (no conflict; the only file the four share is `d3d12/docs/switches.md`). Built with `diagnostics,mimalloc`, target `x86_64-pc-windows-msvc`. RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro (build 26300). Launcher defaults, Series S settings, `-NoDlss -NoFrameGen`, standing at the save; a warm-up run first (the batch changes the translator, so everything was re-translated), then one run of 420 s with the memory safety stop: | | | |---|---| | Reached the world | 71 s | | Time in the world | 349 s | | Device losses | 0 | | Crashes | 0 | | Frame median | 29.4 ms (33.6 fps rendered) | | Card busy | 95 % | | Private memory, max | 26.6 GB | This pull request's own lines: `host-pipelines.driver` was written during the warm-up (stamp with the adapter and driver, `older=1` as the change describes for a pre-existing library), the library then loaded (`pipelines=Older`) and saved with 2,330 pipelines loaded and 47 made, and no "the library did not load it" line appeared. No driver change was exercised here (the driver did not change between runs). Verdict: **PASS** for the batch (a pass covers each of the four; a failure would not have said which). Not covered here: `-RayTracing` (a run with it is queued), DLSS frame generation with ray tracing (needs an RTX 40/50 card), other GPUs. AI-assisted: Claude Code (Claude Opus 5.5)
MoonEyes commented 2026-12-02 17:12:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T17:12:33Z.


Merging. Head 4bd128a8c merges cleanly with main 5b1fff821 and does not force a rebase of #2566. In-game gate: enlight3d's batch run on the RTX 3090 with this head 4bd128a8c merged onto main (lot A: #2643, #3031, #2789, #2661), PASS, comment 7352941075. Independent red/green by MoonEyes' agent on 4bd128a8c: pipeline::library 16 passed, leonida-gpu lib 713 passed; 5 of 5 targeted mutations killed (stamp not compared, stamp ignored on mismatch, old file kept, wrong driver field, line never written), comment 7352861392. CI green incl. no-game-data. Not claimed as the fix for the device-removed reports, which point at #3068. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353050962 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7353050962). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T17:12:33Z. --- Merging. Head `4bd128a8c` merges cleanly with `main` `5b1fff821` and does not force a rebase of #2566. In-game gate: enlight3d's batch run on the RTX 3090 with this head 4bd128a8c merged onto main (lot A: #2643, #3031, #2789, #2661), PASS, comment 7352941075. Independent red/green by MoonEyes' agent on 4bd128a8c: pipeline::library 16 passed, leonida-gpu lib 713 passed; 5 of 5 targeted mutations killed (stamp not compared, stamp ignored on mismatch, old file kept, wrong driver field, line never written), comment 7352861392. CI green incl. no-game-data. Not claimed as the fix for the device-removed reports, which point at #3068. Merged by MoonEyes. AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:29:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:29:45Z.


Verification triage of #2789

Head 4bd128a8c is already verified on this exact head: ninjalegxd, MoonEyes (independent run) and enlight3d (in-game gate run). MoonEyes posted "Merging" on this head at 2026-12-02 17:12. The PR is still open, its merge state is now clean, and CI passes (6/6). No new run here (Windows-only). Verdict: ready (already verified; a maintainer is merging it).

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354682657 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7354682657). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:29:45Z. --- **Verification triage of #2789** Head `4bd128a8c` is already verified on this exact head: ninjalegxd, MoonEyes (independent run) and enlight3d (in-game gate run). MoonEyes posted "Merging" on this head at 2026-12-02 17:12. The PR is still open, its merge state is now `clean`, and CI passes (6/6). No new run here (Windows-only). **Verdict: ready (already verified; a maintainer is merging it).** AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
zmasi commented 2026-12-03 03:32:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-03T03:32:27Z.


Merged origin/main (516c9eaabf) into b511f5c930 strictly to regenerate d3d12/docs/switches.md (needs rebase); d3d12/crates/leonida-gpu/src/pipeline/library.rs has a byte-identical diff against origin/main compared to 4bd128a8c7.

AI-assisted: Gemini 4 Carbon (High) and Gemini 4 Neon (XHigh).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7366675428 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7366675428). Originally posted by [zmasi](https://github.com/zmasi) on 2026-12-03T03:32:27Z. --- Merged `origin/main` (`516c9eaabf`) into `b511f5c930` strictly to regenerate `d3d12/docs/switches.md` (`needs rebase`); `d3d12/crates/leonida-gpu/src/pipeline/library.rs` has a byte-identical diff against `origin/main` compared to `4bd128a8c7`. AI-assisted: Gemini 4 Carbon (High) and Gemini 4 Neon (XHigh).
MoonEyes commented 2026-12-03 04:29:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T04:29:38Z.


RUN (in game, batch of two pull requests), each head merged with git merge --no-ff onto main 516c9eaab, in one build: #2789 b511f5c93, #3072 98a532249. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 16.6, mean 16.6
Rendered fps, last 120 s median 16.3
Time under 5 fps in the world 3 %

For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures; -PrecompileUsed was used, so the default start (every known pipeline precompiled) was not exercised. Both were in earlier batches on other heads; this run covers their current heads. #2789's discard of stale pipeline libraries only acts after a driver update; the driver did not change here, so that path was not exercised.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7367707579 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7367707579). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T04:29:38Z. --- RUN (in game, batch of two pull requests), each head merged with `git merge --no-ff` onto main `516c9eaab`, in one build: #2789 `b511f5c93`, #3072 `98a532249`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, `-PrecompileUsed`, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 16.6, mean 16.6 | | Rendered fps, last 120 s | median 16.3 | | Time under 5 fps in the world | 3 % | For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; arrival in the world was driven by keys and not checked on pictures; `-PrecompileUsed` was used, so the default start (every known pipeline precompiled) was not exercised. Both were in earlier batches on other heads; this run covers their current heads. #2789's discard of stale pipeline libraries only acts after a driver update; the driver did not change here, so that path was not exercised. AI-assisted (Claude Code).
merzleckeier commented 2026-12-03 04:53:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T04:53:24Z.


Integration check on b511f5c9. The head merges cleanly with both #3286 (8c56cb6b) and #2948 (5284c6ea) in separate pairs. I built the #3286 pair for Windows MSVC and ran the synthetic driver-stamp formatting test under Wine. It passed, as did the catalog checker and all 20 catalog tests.

In the merged #3286 source, Host::driver() queries the adapter stored from the created device’s LUID. The pipeline library also finds its descriptor via that device LUID. Thus an explicit WARP selection or a change to the default adapter picker still sources both fields from the device that was actually created. The run covered the CPU stamp fixture. Live adapter switching is outside that test’s scope. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7368151025 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7368151025). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T04:53:24Z. --- Integration check on `b511f5c9`. The head merges cleanly with both #3286 (`8c56cb6b`) and #2948 (`5284c6ea`) in separate pairs. I built the #3286 pair for Windows MSVC and ran the synthetic driver-stamp formatting test under Wine. It passed, as did the catalog checker and all 20 catalog tests. In the merged #3286 source, `Host::driver()` queries the adapter stored from the created device’s LUID. The pipeline library also finds its descriptor via that device LUID. Thus an explicit WARP selection or a change to the default adapter picker still sources both fields from the device that was actually created. The run covered the CPU stamp fixture. Live adapter switching is outside that test’s scope. AI-assisted with OpenAI Codex.
zmasi commented 2026-12-03 11:32:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-03T11:32:42Z.


Merged origin/main (6e97990505, #3318) into 4cd9d71f80 strictly to regenerate d3d12/docs/switches.md (needs rebase); d3d12/crates/leonida-gpu/src/pipeline/library.rs has a byte-identical diff against origin/main compared to b511f5c930.

AI-assisted: Gemini 4 Carbon (High) and Gemini 4 Neon (XHigh).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7376846646 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7376846646). Originally posted by [zmasi](https://github.com/zmasi) on 2026-12-03T11:32:42Z. --- Merged `origin/main` (`6e97990505`, `#3318`) into `4cd9d71f80` strictly to regenerate `d3d12/docs/switches.md` (`needs rebase`); `d3d12/crates/leonida-gpu/src/pipeline/library.rs` has a byte-identical diff against `origin/main` compared to `b511f5c930`. AI-assisted: Gemini 4 Carbon (High) and Gemini 4 Neon (XHigh).
MoonEyes commented 2026-12-03 14:31:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T14:31:58Z.


RUN (in game, third party, batch of five pull requests), each head merged with git merge --no-ff onto main b053a1813, in one build: #2686 c5269801b, #2643 2e0b23a00, #2789 4cd9d71f8, #3072 0f1e26355, #2999 91537d2af. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (46 samples) median 16.3, mean 16.4
Rendered fps, last 120 s median 16.2
Frames over 100 ms 21.3 per 1000; 2 pauses over 1 s
Time under 5 fps in the world 0 %

For reference, the same machine and route rendered 13.3 to 17.6 fps on other runs today: a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. #2834 was left out of the batch (it conflicts with the others).

Limits: one run; arrival in the world was driven by keys and not checked on pictures. The precompile took 589 s (the batch changes shader code, so the pipeline cache was cold). Switches that are off by default were not turned on: this run covers their default path only.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7381602367 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2789#issuecomment-7381602367). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T14:31:58Z. --- RUN (in game, third party, batch of five pull requests), each head merged with `git merge --no-ff` onto main `b053a1813`, in one build: #2686 `c5269801b`, #2643 `2e0b23a00`, #2789 `4cd9d71f8`, #3072 `0f1e26355`, #2999 `91537d2af`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, `-PrecompileUsed`, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (46 samples) | median 16.3, mean 16.4 | | Rendered fps, last 120 s | median 16.2 | | Frames over 100 ms | 21.3 per 1000; 2 pauses over 1 s | | Time under 5 fps in the world | 0 % | For reference, the same machine and route rendered 13.3 to 17.6 fps on other runs today: a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. #2834 was left out of the batch (it conflicts with the others). Limits: one run; arrival in the world was driven by keys and not checked on pictures. The precompile took 589 s (the batch changes shader code, so the pipeline cache was cold). Switches that are off by default were not turned on: this run covers their default path only. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2789:upstream-pr/2789'
git switch 'upstream-pr/2789'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2789'
git switch 'upstream-pr/2789'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2789'
git switch 'upstream-pr/2789'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2789'
git switch 'main'
git merge --squash 'upstream-pr/2789'
git switch 'main'
git merge --ff-only 'upstream-pr/2789'
git switch 'main'
git merge 'upstream-pr/2789'
git push origin 'main'
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!2789
No description provided.