d3d12: start this game's NVIDIA shader cache afresh when it was found full #3511

Code

Clone this repository

Checkout

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

git fetch -u origin "+refs/pull/3511/head:oreofr/driver-cache-fresh"
git switch "oreofr/driver-cache-fresh"
Open
leonida/mandy
OreoFR wants to merge 2 commits from oreofr/driver-cache-fresh 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/3511/head:oreofr/driver-cache-fresh'
git switch 'oreofr/driver-cache-fresh'
Member

Item: D3D12-DRIVER-CACHE-FRESH (asked by OreoFR, 2026-12-05).

Problem. NVIDIA's shader cache for this game (%LOCALAPPDATA%\NVIDIA\DXCache, keyed by the program, so main and beta share it) fills up with the pipelines of older translations: every translator change adds a full set on top. Once full, the driver keeps nothing new while warm-done.txt says every pipeline was made, so every start compiles in game. On an RTX 4070 the files held 13 GB and were full; after a fresh start the whole game's pipelines took 2.5 GB, and in-game compiles at spawn went from 485 to 9.

Change (d3d12/scripts/play-nvidia.ps1, the block between "Begin/End of the fresh driver cache block"):

  • When the last precompile found the cache full (driver-cache-full.txt, written by the existing "cache is full" warning), the next start removes the .nvph files this game's precompiles wrote (only those named in driver-cache-files.txt), puts warm-done.txt aside and precompiles every pipeline again (--again).
  • A precompile that started afresh never marks the cache full again. The full check is a guess (a .nvph file of 4 GB+ written during the precompile), and it fires even with Shader Cache Size set to Unlimited (seen on an RTX 5080), where the driver keeps a 4 GB first file. Without this, a translation that fills that file by itself would empty the cache and precompile for an hour at every start. In that case the warning asks the player to delete the file by hand.
  • LEONIDA_DRIVER_CACHE_FRESH=0 turns it off.

Changed in review (dd6609a49). The first version also emptied the cache whenever a new translation had never been precompiled here. That meant an hour of precompile at every update and every main/beta switch, so it was dropped. Reusing what the driver already has for a new translation (precompile marks named by the translated code, like Darner's DARNER_PRELOAD_KEEP_MARKS) is a separate change.

Tested (Windows 11, no game needed):

  • tests/test_play_driver_cache_fresh.py: 6 OK. The block is run alone in Windows PowerShell with a stand-in for leonida.exe and temporary folders: full cache emptied, new translation alone left alone, switch off, nothing without the files' note, the full mark not written after a fresh start.
  • Play script tests and test_d3d12_switches: OK. PowerShell parse check: no errors.
  • Not run in game yet.

AI-assisted (oreofr-agent).

🤖 Generated with Claude Code

Item: D3D12-DRIVER-CACHE-FRESH (asked by OreoFR, 2026-12-05). **Problem.** NVIDIA's shader cache for this game (`%LOCALAPPDATA%\NVIDIA\DXCache`, keyed by the program, so main and beta share it) fills up with the pipelines of older translations: every translator change adds a full set on top. Once full, the driver keeps nothing new while `warm-done.txt` says every pipeline was made, so every start compiles in game. On an RTX 4070 the files held 13 GB and were full; after a fresh start the whole game's pipelines took 2.5 GB, and in-game compiles at spawn went from 485 to 9. **Change** (`d3d12/scripts/play-nvidia.ps1`, the block between "Begin/End of the fresh driver cache block"): - When the last precompile found the cache full (`driver-cache-full.txt`, written by the existing "cache is full" warning), the next start removes the `.nvph` files this game's precompiles wrote (only those named in `driver-cache-files.txt`), puts `warm-done.txt` aside and precompiles every pipeline again (`--again`). - **A precompile that started afresh never marks the cache full again.** The full check is a guess (a `.nvph` file of 4 GB+ written during the precompile), and it fires even with Shader Cache Size set to Unlimited (seen on an RTX 5080), where the driver keeps a 4 GB first file. Without this, a translation that fills that file by itself would empty the cache and precompile for an hour at every start. In that case the warning asks the player to delete the file by hand. - `LEONIDA_DRIVER_CACHE_FRESH=0` turns it off. **Changed in review (dd6609a49).** The first version also emptied the cache whenever a new translation had never been precompiled here. That meant an hour of precompile at every update and every main/beta switch, so it was dropped. Reusing what the driver already has for a new translation (precompile marks named by the translated code, like Darner's `DARNER_PRELOAD_KEEP_MARKS`) is a separate change. **Tested** (Windows 11, no game needed): - `tests/test_play_driver_cache_fresh.py`: 6 OK. The block is run alone in Windows PowerShell with a stand-in for leonida.exe and temporary folders: full cache emptied, new translation alone left alone, switch off, nothing without the files' note, the full mark not written after a fresh start. - Play script tests and `test_d3d12_switches`: OK. PowerShell parse check: no errors. - **Not run in game yet.** AI-assisted (oreofr-agent). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Before the precompile, play-nvidia.ps1 now removes the driver files this
game's precompiles wrote (driver-cache-files.txt) and puts warm-done.txt
aside when the current translation was never precompiled here (asked with
`leonida warm --limit 0`: 0 made before, while warm-done.txt knows others)
or when the last precompile found the cache full (driver-cache-full.txt,
now written beside the existing warning). Every pipeline is then made
again once. LEONIDA_DRIVER_CACHE_FRESH=0 keeps the old behaviour.

Why: each new translation's pipelines went on top of the old ones in the
same driver files (main and beta share them: the driver keys them by the
program), until the cache was full. From then on the driver kept nothing
new while warm-done.txt said all was made, and every start compiled in
the game. RTX 4070, 2026-12-05: this game's files held 13 GB and were
full; after a fresh start the whole game's pipelines took 2.5 GB, and the
spawn compiled 9 pipelines in the game instead of 485. Darner does the
same with its own cache when a build translates differently.

Tests: tests/test_play_driver_cache_fresh.py (new, 6, the block run alone
in PowerShell on temporary folders), test_d3d12_switches (switches.md
regenerated), test_play_nvidia_menu_choice, test_text_write_line_endings,
no game data. Not yet run in the game.

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

Independent local verification of this change (I changed no code).

  • Head c3d7c983, merge base f4b0404e. The six new cases are absent on the base: git grep -F test_a_new_translation_starts_the_cache_afresh f4b0404e -- tests -> exit 1.
  • On the PR head: python -I -m unittest discover -s tests -p test_play_driver_cache_fresh.py -> Ran 6 tests in 3.3 s, OK. Nothing was skipped: the class is skipUnless(os.name == "nt") and this host is Windows.
  • These are mostly behaviour, not text greps: five of the six extract the block between its begin/end markers and run it under powershell.exe in a temp folder with a stub leonida warm and stub cache files, then assert on what is left behind (which cache files are removed, which are kept, whether warm-done.txt is put aside as .old, whether --again is passed, and that LEONIDA_DRIVER_CACHE_FRESH=0 turns it off). The sixth, test_the_precompile_says_when_the_cache_is_full_and_marks_it, is a text check for Set-Content -Path $fullMark in the script. The PC's real driver cache and the game are not touched.
  • git diff --check f4b0404e c3d7c983 -> clean. python -I scripts/check_no_game_data.py on tests/test_play_driver_cache_fresh.py, d3d12/scripts/play-nvidia.ps1 and d3d12/docs/switches.md -> clean.

What it does not cover: the script's own invocation path into the real leonida warm and a real NVIDIA cache being rebuilt; the block is exercised against a stand-in.

GPUs tested: none (PowerShell fixture with stub files; no game run and no card). Driver: n/a. No game data, assets or extracted shaders were used or attached.

AI-assisted: yes, Hy4 flash (verification only). No approval implied.

Independent local verification of this change (I changed no code). - Head `c3d7c983`, merge base `f4b0404e`. The six new cases are absent on the base: `git grep -F test_a_new_translation_starts_the_cache_afresh f4b0404e -- tests` -> exit 1. - On the PR head: `python -I -m unittest discover -s tests -p test_play_driver_cache_fresh.py` -> Ran 6 tests in 3.3 s, OK. Nothing was skipped: the class is `skipUnless(os.name == "nt")` and this host is Windows. - These are mostly behaviour, not text greps: five of the six extract the block between its begin/end markers and run it under `powershell.exe` in a temp folder with a stub `leonida warm` and stub cache files, then assert on what is left behind (which cache files are removed, which are kept, whether `warm-done.txt` is put aside as `.old`, whether `--again` is passed, and that `LEONIDA_DRIVER_CACHE_FRESH=0` turns it off). The sixth, `test_the_precompile_says_when_the_cache_is_full_and_marks_it`, is a text check for `Set-Content -Path $fullMark` in the script. The PC's real driver cache and the game are not touched. - `git diff --check f4b0404e c3d7c983` -> clean. `python -I scripts/check_no_game_data.py` on tests/test_play_driver_cache_fresh.py, d3d12/scripts/play-nvidia.ps1 and d3d12/docs/switches.md -> clean. What it does not cover: the script's own invocation path into the real `leonida warm` and a real NVIDIA cache being rebuilt; the block is exercised against a stand-in. GPUs tested: none (PowerShell fixture with stub files; no game run and no card). Driver: n/a. No game data, assets or extracted shaders were used or attached. AI-assisted: yes, Hy4 flash (verification only). No approval implied.
Review of this change: a precompile whose driver file reached 4 GB marked the cache full, and the next
start emptied it and made every pipeline again. A player on an RTX 5080 with Shader Cache Size set to
Unlimited got that warning anyway (the driver keeps a 4 GB first file there): if one translation's
pipelines fill that file by themselves, every start would have emptied the cache and precompiled for an
hour. A precompile that started afresh now never marks the cache full; its warning says to delete the
file by hand if it stays full.

A new translation alone no longer empties the cache either (its `warm --limit 0` probe is gone): that
cost an hour of precompile at every update and every main/beta switch, while the cache only needs it
once it is full. Making a new translation reuse what the driver already has is a separate change.

Tested: tests/test_play_driver_cache_fresh.py (6), the play script tests, test_d3d12_switches,
PowerShell parse check. AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OreoFR changed title from d3d12: start this game's NVIDIA shader cache afresh on a new translation or when full to d3d12: start this game's NVIDIA shader cache afresh when it was found full 2026-12-05 05:55:10 +00:00
First-time contributor

Re-verified after the rewrite. This head (dd6609a49) is a different change from the one my earlier comment (26783) covered: the "new translation empties the cache" half is gone, and the old comment no longer describes this PR.

New at this head. tests/test_play_driver_cache_fresh.py is absent on the base 93b9d90a and holds six cases matching the new behaviour (a_new_translation_alone_keeps_the_cache, a_cache_seen_full_is_started_afresh, the_precompile_marks_a_full_cache_unless_it_started_afresh, the switch, and the no-file-list case). They run the real play-nvidia.ps1 block in Windows PowerShell with a stand-in leonida.exe and temporary folders, so they execute the changed path; d3d12/docs/switches.md is regenerated in the same diff.

python -I -m unittest discover -s tests -p test_play_driver_cache_fresh.py -v   # Ran 6 tests in 3.129s — OK
python -I -m unittest discover -s tests -p test_d3d12_switches.py               # Ran 22 tests in 13.596s — OK

git diff --check against 93b9d90a: clean. scripts/check_no_game_data.py on the three changed files: clean.

Limits. The tests use a fake leonida and temp folders — no game, no driver cache of this PC touched (as the file's docstring says). The premise that a 4 GB first driver file can fill on its own, and that a fresh start now never repeats twice in a row, stays the author's RTX 5080/4070 evidence; not reproduced here.

AI-assisted (Hy4 flash). GPU: RTX 5060 Laptop (driver 621.40) and Radeon 780M present, unused by these tests. No game data used or needed.

Re-verified after the rewrite. This head (dd6609a49) is a different change from the one my earlier comment (26783) covered: the "new translation empties the cache" half is gone, and the old comment no longer describes this PR. **New at this head.** `tests/test_play_driver_cache_fresh.py` is absent on the base `93b9d90a` and holds six cases matching the new behaviour (`a_new_translation_alone_keeps_the_cache`, `a_cache_seen_full_is_started_afresh`, `the_precompile_marks_a_full_cache_unless_it_started_afresh`, the switch, and the no-file-list case). They run the real `play-nvidia.ps1` block in Windows PowerShell with a stand-in `leonida.exe` and temporary folders, so they execute the changed path; `d3d12/docs/switches.md` is regenerated in the same diff. ```powershell python -I -m unittest discover -s tests -p test_play_driver_cache_fresh.py -v # Ran 6 tests in 3.129s — OK python -I -m unittest discover -s tests -p test_d3d12_switches.py # Ran 22 tests in 13.596s — OK ``` `git diff --check` against `93b9d90a`: clean. `scripts/check_no_game_data.py` on the three changed files: clean. **Limits.** The tests use a fake `leonida` and temp folders — no game, no driver cache of this PC touched (as the file's docstring says). The premise that a 4 GB first driver file can fill on its own, and that a fresh start now never repeats twice in a row, stays the author's RTX 5080/4070 evidence; not reproduced here. AI-assisted (Hy4 flash). GPU: RTX 5060 Laptop (driver 621.40) and Radeon 780M present, unused by these tests. No game data used or needed.
Sign in to join this conversation.
No description provided.