d3d12 pipeline library: a library another translator wrote is set aside (D3D12-LIBRARY-TRANSLATOR-MARK) #3459

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u origin "+refs/pull/3459/head:oreofr/library-translator-mark"
git switch "oreofr/library-translator-mark"
Open
leonida/mandy
OreoFR wants to merge 1 commit from oreofr/library-translator-mark into main AGit

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3459/head:oreofr/library-translator-mark'
git switch 'oreofr/library-translator-mark'
Member

Claimed in the coordination issue (#3312) as: D3D12-LIBRARY-TRANSLATOR-MARK
Proposed by MoonEyes on the agents' bridge.

What and why

The host refuses a pipeline library of another adapter or driver (pipeline/library.rs, module notes), but not one another translator filled. After an update that changes the shader translation, every pipeline of a changed shader is made again under a new name and the old entries stay in the library: never asked for again, written out by every save, gone through by every load. d3d12/docs/findings.md (around line 592) has the library growing from 1.64 to 2.02 GB after one translator change. Darner measured a preload of 80 min with an old library against 10 min with none (Darner 34b0ba77e, its issue #188; not measured here).

  • Every save (replace_library) writes this build's translator hash, env!("LEONIDA_TRANSLATOR") (the same value the shader cache uses, shader_cache.rs), to host-pipelines.translator beside the library.
  • At start (set_aside_if_stale, before the library is read or mapped), a library with another mark, or with none (saved before this change), is renamed to host-pipelines.old-<first 16 chars of its mark>.bin (old-unmarked for none), not deleted. One line says why and how many bytes, then an empty library starts. A pending host-pipelines.next is settled first and counts as the library.
  • Only the newest library set aside is kept. An older host-pipelines.old-*.bin is removed, with its own line and size, so each translator change does not leave another 2 GB on disk.
  • LEONIDA_LIBRARY_KEEP_OLD=1 loads the old library as before. Its next save then marks it as this translator's.
  • The translator's runtime settings (LEONIDA_WAVE_WIDE and the like) are deliberately not part of the mark, so trying a switch for one run does not throw away the library.
  • Logging (Darner f31758467): a StorePipeline refused for another reason than E_INVALIDARG (a name stored already) is logged once with its HRESULT, then at each power of two from 1,024. A library that serialises to 0 bytes after stores is logged too. Before, a driver refusing every store left saves of 0 bytes and nothing in the log.
  • Docs: d3d12/docs/switches.md regenerated (LEONIDA_LIBRARY_KEEP_OLD); new entry in d3d12/docs/findings.md.

Relation to #2781 / #2789: that work is about a driver change (a library the driver accepts whole but whose entries it then refuses). This one is about the translator. They touch the same file but not the same logic. If #2789 lands first, the rebase is mechanical. The early-pipeline and slow lists are kept, since they are keyed by title pipeline and not by translation. warm --store's library_done already treats a missing host-pipelines.bin as "nothing stored".

Credit

Ported from Darner (https://git.gtahub.st/TrustNo1/Darner, GPL-3.0-or-later) and rewritten for Mandy's library, since the histories are unrelated:

  • 34b0ba77e (trustno1-coder): a library written by another build's translator is not loaded, with a keep-old switch.
  • f3840d73d, Darner PR #192 by tyr0nsur: also the old root, plus the DARNER_LIBRARY_KEEP_OLD=1 escape hatch. Mandy has no separate root, so only the switch carries over.
  • f31758467 (trustno1-coder): log when the driver refuses to store pipelines (saves of 0 bytes).

Tested

  • cargo test --locked -p leonida-gpu: 759 passed, 0 failed (60 ignored).
  • New unit tests in pipeline::library:
    • a_library_of_another_translator_or_none_is_set_aside: our mark, another mark, an empty mark, no mark, keep-old.
    • a_library_set_aside_is_named_by_its_mark: naming, including a damaged mark.
    • a_stale_library_is_moved_aside_and_a_save_marks_the_new_one: on a temp folder, covers moved not deleted, save writes the mark, keep-old, only the newest kept, and .next settled.
    • only_refusals_other_than_a_name_stored_already_are_said.
  • Red/green: with verdict forced to the old behaviour (always load), the two set-aside tests fail. With the change, all 10 library tests pass.
  • cargo clippy --locked -p leonida-gpu --all-targets -- -D warnings: clean.
  • cargo build --locked --profile diag -p leonida --features diagnostics,dlss,mimalloc: builds. The only warning is the existing book.rs:247 dead field, which is not from this change.
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md and python -I tests/test_d3d12_switches.py (22 tests): OK.
  • python -I scripts/check_no_game_data.py on the three changed files: OK. git merge-tree with current main: clean.
  • Tested on RTX 4070 Laptop, Windows 11, no in-game run yet. Still to measure in game: the first start after a translator change, with and without this change (preload time, library size). Expected log line: "host pipeline library set aside".

AI-assisted: yes (Claude Opus 5.5 via Claude Code).

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • 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

Claimed in the coordination issue (#3312) as: `D3D12-LIBRARY-TRANSLATOR-MARK` Proposed by MoonEyes on the agents' bridge. ### What and why The host refuses a pipeline library of another adapter or driver (`pipeline/library.rs`, module notes), but not one another translator filled. After an update that changes the shader translation, every pipeline of a changed shader is made again under a new name and the old entries stay in the library: never asked for again, written out by every save, gone through by every load. `d3d12/docs/findings.md` (around line 592) has the library growing from 1.64 to 2.02 GB after one translator change. Darner measured a preload of 80 min with an old library against 10 min with none (Darner 34b0ba77e, its issue #188; not measured here). - Every save (`replace_library`) writes this build's translator hash, `env!("LEONIDA_TRANSLATOR")` (the same value the shader cache uses, `shader_cache.rs`), to `host-pipelines.translator` beside the library. - At start (`set_aside_if_stale`, before the library is read or mapped), a library with another mark, or with none (saved before this change), is **renamed** to `host-pipelines.old-<first 16 chars of its mark>.bin` (`old-unmarked` for none), not deleted. One line says why and how many bytes, then an empty library starts. A pending `host-pipelines.next` is settled first and counts as the library. - Only the newest library set aside is kept. An older `host-pipelines.old-*.bin` is removed, with its own line and size, so each translator change does not leave another 2 GB on disk. - `LEONIDA_LIBRARY_KEEP_OLD=1` loads the old library as before. Its next save then marks it as this translator's. - The translator's runtime settings (`LEONIDA_WAVE_WIDE` and the like) are deliberately not part of the mark, so trying a switch for one run does not throw away the library. - Logging (Darner f31758467): a `StorePipeline` refused for another reason than `E_INVALIDARG` (a name stored already) is logged once with its HRESULT, then at each power of two from 1,024. A library that serialises to 0 bytes after stores is logged too. Before, a driver refusing every store left saves of 0 bytes and nothing in the log. - Docs: `d3d12/docs/switches.md` regenerated (`LEONIDA_LIBRARY_KEEP_OLD`); new entry in `d3d12/docs/findings.md`. **Relation to #2781 / #2789:** that work is about a driver change (a library the driver accepts whole but whose entries it then refuses). This one is about the translator. They touch the same file but not the same logic. If #2789 lands first, the rebase is mechanical. The early-pipeline and slow lists are kept, since they are keyed by title pipeline and not by translation. `warm --store`'s `library_done` already treats a missing `host-pipelines.bin` as "nothing stored". ### Credit Ported from Darner (https://git.gtahub.st/TrustNo1/Darner, GPL-3.0-or-later) and rewritten for Mandy's library, since the histories are unrelated: - 34b0ba77e (trustno1-coder): a library written by another build's translator is not loaded, with a keep-old switch. - f3840d73d, Darner PR #192 by tyr0nsur: also the old root, plus the `DARNER_LIBRARY_KEEP_OLD=1` escape hatch. Mandy has no separate root, so only the switch carries over. - f31758467 (trustno1-coder): log when the driver refuses to store pipelines (saves of 0 bytes). ### Tested - `cargo test --locked -p leonida-gpu`: 759 passed, 0 failed (60 ignored). - New unit tests in `pipeline::library`: - `a_library_of_another_translator_or_none_is_set_aside`: our mark, another mark, an empty mark, no mark, keep-old. - `a_library_set_aside_is_named_by_its_mark`: naming, including a damaged mark. - `a_stale_library_is_moved_aside_and_a_save_marks_the_new_one`: on a temp folder, covers moved not deleted, save writes the mark, keep-old, only the newest kept, and `.next` settled. - `only_refusals_other_than_a_name_stored_already_are_said`. - Red/green: with `verdict` forced to the old behaviour (always load), the two set-aside tests fail. With the change, all 10 library tests pass. - `cargo clippy --locked -p leonida-gpu --all-targets -- -D warnings`: clean. - `cargo build --locked --profile diag -p leonida --features diagnostics,dlss,mimalloc`: builds. The only warning is the existing `book.rs:247` dead field, which is not from this change. - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` and `python -I tests/test_d3d12_switches.py` (22 tests): OK. - `python -I scripts/check_no_game_data.py` on the three changed files: OK. `git merge-tree` with current `main`: clean. - Tested on RTX 4070 Laptop, Windows 11, no in-game run yet. Still to measure in game: the first start after a translator change, with and without this change (preload time, library size). Expected log line: "host pipeline library set aside". AI-assisted: yes (Claude Opus 5.5 via Claude Code). ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [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)
The host refuses a pipeline library of another adapter or driver, not one
another translator filled: after a translator change the old entries stay,
are saved again and slow every load (1.64 -> 2.02 GB here, findings.md;
on Darner a preload of 80 min with an old library against 10 with none).

Every save now writes the translator's hash (LEONIDA_TRANSLATOR, as the
shader cache uses) to host-pipelines.translator. At start a library of
another mark, or of none, is renamed to host-pipelines.old-<mark>.bin with
a line saying why and how large, and an empty one starts; only the newest
one set aside is kept. LEONIDA_LIBRARY_KEEP_OLD=1 keeps it. A store the
driver refuses for another reason than a name stored already, and a
library that serialises to 0 bytes, are logged.

Ported from Darner (TrustNo1/Darner, GPL-3.0-or-later) and rewritten:
34b0ba77e and f31758467 by trustno1-coder, f3840d73d (Darner PR #192 by
tyr0nsur).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First-time contributor

Verification — Merge, Unit/GPU Tests & Checks (NVIDIA RTX 5070 12 GB, Windows 11)

Tested PR head 77775007b8 merged cleanly onto main (00e245be5):

  • cargo test -p leonida-gpu --lib --locked pipeline::library:: — 10/10 PASS (including a_library_of_another_translator_or_none_is_set_aside, a_library_set_aside_is_named_by_its_mark, a_stale_library_is_moved_aside_and_a_save_marks_the_new_one, a_rejected_blob_gives_an_empty_library)
  • cargo clippy -p leonida-gpu --all-targets --locked -- -D warnings — 0 warnings
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md — PASS
  • python -I scripts/check_no_game_data.py — PASS

Clean merge and all library unit/GPU tests pass. (Note: unit/device tests only here; no full in-game run was executed in this pass.)

AI-assisted.

### Verification — Merge, Unit/GPU Tests & Checks (NVIDIA RTX 5070 12 GB, Windows 11) Tested PR head `77775007b8` merged cleanly onto `main` (`00e245be5`): - `cargo test -p leonida-gpu --lib --locked pipeline::library::` — **`10/10` PASS** (including `a_library_of_another_translator_or_none_is_set_aside`, `a_library_set_aside_is_named_by_its_mark`, `a_stale_library_is_moved_aside_and_a_save_marks_the_new_one`, `a_rejected_blob_gives_an_empty_library`) - `cargo clippy -p leonida-gpu --all-targets --locked -- -D warnings` — `0` warnings - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` — PASS - `python -I scripts/check_no_game_data.py` — PASS Clean merge and all library unit/GPU tests pass. (Note: unit/device tests only here; no full in-game run was executed in this pass.) AI-assisted.
Sign in to join this conversation.
No description provided.