run_game_wine.sh: keep the drivers' shader cache from run to run (WINE-RUN-SHADER-CACHE) #2436

Manually merged
github merged 5 commits from github-bot/gh-2436 into gh-pr/2436/base 2026-12-01 11:31:51 +00:00 AGit
Owner

@⁠kawaii-shakal on GitHub · 2026-11-27 06:49 UTC · original
kawaii-shakal:wine-run-shader-cache → main · +95 −5 · 4 files · 5 commits · merged 2026-12-01 11:30 UTC

Claimed in the coordination issue as: WINE-RUN-SHADER-CACHE (finding by z3r0rc in #1608, its shader-cache part)

What and why

scripts/run_game_wine.sh exported XDG_CACHE_HOME=$RUN/session/cache, a new folder in each run folder. NVIDIA's
GLCache and Mesa's shader cache live under XDG_CACHE_HOME, so every launch started with an empty driver cache and
compiled its pipelines again.

  • The caller's XDG_CACHE_HOME is used when it is set; --cache DIR names a folder instead. Both are kept from run
    to run.
  • --cache fresh, or neither of the two, gives the old behaviour: a new folder in the run folder, for a cold-cache
    measurement.
  • The first line of the printed summary says which (shader cache: kept in DIR or shader cache: fresh).
  • --help and docs/linux_proton.md describe it.

Not in this PR: the compile-gate defaults from the same finding (LEONIDA_COMPILE_HELPER, LEONIDA_ASYNC_PIPELINES),
which need a retail run to judge.

Tested

  • tests/test_run_game_wine.py, three new cases against the script's stubs: a fresh cache by default; the caller's
    cache kept across two runs (the stub wine appends to nvidia/GLCache, and the second run finds the first's
    line); --cache DIR and --cache fresh over a caller's XDG_CACHE_HOME.
  • Ubuntu 24.04 container, bash 5.2, Python 3.12. No Wine, GPU or game.

AI-assisted: yes (Claude Code)

Checklist

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

🤖 Generated with Claude Code

**@⁠kawaii-shakal** on GitHub · 2026-11-27 06:49 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436) `kawaii-shakal:wine-run-shader-cache` → `main` · +95 −5 · 4 files · 5 commits · merged 2026-12-01 11:30 UTC Claimed in the coordination issue as: WINE-RUN-SHADER-CACHE (finding by z3r0rc in #1608, its shader-cache part) ### What and why `scripts/run_game_wine.sh` exported `XDG_CACHE_HOME=$RUN/session/cache`, a new folder in each run folder. NVIDIA's `GLCache` and Mesa's shader cache live under `XDG_CACHE_HOME`, so every launch started with an empty driver cache and compiled its pipelines again. - The caller's `XDG_CACHE_HOME` is used when it is set; `--cache DIR` names a folder instead. Both are kept from run to run. - `--cache fresh`, or neither of the two, gives the old behaviour: a new folder in the run folder, for a cold-cache measurement. - The first line of the printed summary says which (`shader cache: kept in DIR` or `shader cache: fresh`). - `--help` and `docs/linux_proton.md` describe it. Not in this PR: the compile-gate defaults from the same finding (`LEONIDA_COMPILE_HELPER`, `LEONIDA_ASYNC_PIPELINES`), which need a retail run to judge. ### Tested - `tests/test_run_game_wine.py`, three new cases against the script's stubs: a fresh cache by default; the caller's cache kept across two runs (the stub `wine` appends to `nvidia/GLCache`, and the second run finds the first's line); `--cache DIR` and `--cache fresh` over a caller's `XDG_CACHE_HOME`. - Ubuntu 24.04 container, bash 5.2, Python 3.12. No Wine, GPU or game. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption. - [ ] 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)
Finding by z3r0rc in #1608: the launcher set XDG_CACHE_HOME to a new folder in each run folder, so NVIDIA's GLCache
(and Mesa's shader cache) started empty on every launch. The caller's XDG_CACHE_HOME is now used when it is set,
--cache DIR names one, and --cache fresh keeps the old cold-cache behaviour. session.txt says which.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 06:50:56 +00:00
Author
Owner

@⁠kirigayakazima on GitHub · 2026-11-28 03:27 UTC · original

#2436 | head 6fe01249f6 | python -I tests/test_run_game_wine.py | red: ModuleNotFoundError: No module named 'fcntl' (PR branch predates main's Windows skip guard) | green: OK (skipped=12 on Windows 11 after merging main's Linux-only guard) | full suite: same as main (514/521 standalone stdlib tests passed, 0 new failures vs main 02f71ccfe7; compileall=0; node viewer_streaming=0) | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini)

  • Clean merge onto main 02f71ccfe7; scripts/check_no_game_data.py passed (0).
  • Note: tests/test_run_game_wine.py is Linux-only (fcntl / bash / Wine stub), so all 12 tests skip on Windows once main is merged. A Linux runner still needs to verify the live Red -> Green XDG_CACHE_HOME assertions for VERIFY-2436.
**@⁠kirigayakazima** on GitHub · 2026-11-28 03:27 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7233091648) #2436 | head 6fe01249f668cbc5b5b659d5fc91e87c754f81f7 | python -I tests/test_run_game_wine.py | red: ModuleNotFoundError: No module named 'fcntl' (PR branch predates main's Windows skip guard) | green: OK (skipped=12 on Windows 11 after merging main's Linux-only guard) | full suite: same as main (514/521 standalone stdlib tests passed, 0 new failures vs main 02f71ccfe7; compileall=0; node viewer_streaming=0) | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini) - Clean merge onto `main` `02f71ccfe7`; `scripts/check_no_game_data.py` passed (`0`). - Note: `tests/test_run_game_wine.py` is Linux-only (`fcntl` / `bash` / Wine stub), so all 12 tests skip on Windows once `main` is merged. A Linux runner still needs to verify the live Red -> Green `XDG_CACHE_HOME` assertions for `VERIFY-2436`.
Author
Owner

@⁠merzleckeier on GitHub · 2026-11-28 20:46 UTC · original

Linux verification for VERIFY-2436 on CachyOS (kernel 7.3.6-3, Bash 5.3.20, Python 3.14.10). Head e73386f5 merged cleanly into main at 1bc055e6.

I ran the same current python -I tests/test_run_game_wine.py -v fixture before and after, changing only which runner it called. On bare main with the PR fixture, 9 passed and the 3 new cases failed as expected. The old runner ignores the caller's cache, rejects --cache and uses the expected fresh directory without the new status line. With the PR, 12/12 passed with no skips. That covers the default fresh cache, the caller's cache surviving two stub launches, and both forms of the explicit override (directory or fresh).

The cases ran offline with Wine stubs. No game files or GPU work were needed. AI-assisted with Codex.

**@⁠merzleckeier** on GitHub · 2026-11-28 20:46 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7245529539) Linux verification for `VERIFY-2436` on CachyOS (kernel 7.3.6-3, Bash 5.3.20, Python 3.14.10). Head `e73386f5` merged cleanly into `main` at `1bc055e6`. I ran the same current `python -I tests/test_run_game_wine.py -v` fixture before and after, changing only which runner it called. On bare `main` with the PR fixture, 9 passed and the 3 new cases failed as expected. The old runner ignores the caller's cache, rejects `--cache` and uses the expected fresh directory without the new status line. With the PR, 12/12 passed with no skips. That covers the default fresh cache, the caller's cache surviving two stub launches, and both forms of the explicit override (directory or `fresh`). The cases ran offline with Wine stubs. No game files or GPU work were needed. AI-assisted with Codex.
Author
Owner

@⁠TheGeogeo on GitHub · 2026-11-28 23:38 UTC · original

Tested e73386f5b merged (no commit) with main aa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Not testable here: tests/test_run_game_wine.py skips all of its 12 tests on Windows (it needs bash and Wine). Green and red can't be observed on this machine, so this is diff reading only.

AI-assisted (Claude Code).

**@⁠TheGeogeo** on GitHub · 2026-11-28 23:38 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7247560787) Tested `e73386f5b` merged (no commit) with `main` `aa918e5d9`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Not testable here: `tests/test_run_game_wine.py` skips all of its 12 tests on Windows (it needs `bash` and Wine). Green and red can't be observed on this machine, so this is diff reading only. AI-assisted (Claude Code).
Author
Owner

@⁠zmasi on GitHub · 2026-11-29 01:40 UTC · original

Independent verification on Windows 11 (10.0.26200, x64, Git Bash + Python 3.12.10 & Python 3.14.5) with e73386f5bc merged onto origin/main (0efc2bd43d, 0 merge conflicts):

  • Git Bash CLI Red -> Green (scripts/run_game_wine.sh):
    • Red (origin/main): bash scripts/run_game_wine.sh --cache fresh exits 2 (run_game_wine.sh: unknown argument: --cache (see --help)).
    • Green (e73386f5bc merged onto origin/main): bash -n scripts/run_game_wine.sh exits 0, bash scripts/run_game_wine.sh --help exits 0 and documents --cache DIR|fresh, and bash scripts/run_game_wine.sh --cache "" exits 2 (run_game_wine.sh: --cache needs a value (see --help)).
  • Python & documentation gates:
    • python -I -B tests/test_run_game_wine.py: Ran 12 tests, OK (skipped=12) on Windows under both Python 3.12.10 and Python 3.14.5 (matching the Linux-only guard).
    • python -I tests/test_docs_table_rows.py (2/2), python -I tests/test_docs_repeated_lines.py (3/3), python -I tests/test_ci_registration.py (18/18), and python -I tests/test_text_write_line_endings.py (3/3) all exited 0; test_docs_cli_flags.py and test_docs_links.py add 0 issues on docs/linux_proton.md or scripts/run_game_wine.sh.
  • Hygiene: git diff --check and python -I scripts/check_no_game_data.py across all 3 touched files exited 0.

AI-assisted.

**@⁠zmasi** on GitHub · 2026-11-29 01:40 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7248938209) Independent verification on Windows 11 (`10.0.26200`, x64, Git Bash + `Python 3.12.10` & `Python 3.14.5`) with `e73386f5bc` merged onto `origin/main` (`0efc2bd43d`, `0` merge conflicts): - **Git Bash CLI Red -> Green (`scripts/run_game_wine.sh`)**: - Red (`origin/main`): `bash scripts/run_game_wine.sh --cache fresh` exits `2` (`run_game_wine.sh: unknown argument: --cache (see --help)`). - Green (`e73386f5bc` merged onto `origin/main`): `bash -n scripts/run_game_wine.sh` exits `0`, `bash scripts/run_game_wine.sh --help` exits `0` and documents `--cache DIR|fresh`, and `bash scripts/run_game_wine.sh --cache ""` exits `2` (`run_game_wine.sh: --cache needs a value (see --help)`). - **Python & documentation gates**: - `python -I -B tests/test_run_game_wine.py`: `Ran 12 tests`, `OK (skipped=12)` on Windows under both `Python 3.12.10` and `Python 3.14.5` (matching the Linux-only guard). - `python -I tests/test_docs_table_rows.py` (`2/2`), `python -I tests/test_docs_repeated_lines.py` (`3/3`), `python -I tests/test_ci_registration.py` (`18/18`), and `python -I tests/test_text_write_line_endings.py` (`3/3`) all exited `0`; `test_docs_cli_flags.py` and `test_docs_links.py` add `0` issues on `docs/linux_proton.md` or `scripts/run_game_wine.sh`. - **Hygiene**: `git diff --check` and `python -I scripts/check_no_game_data.py` across all 3 touched files exited `0`. AI-assisted.
Author
Owner

@⁠timbot103 on GitHub · 2026-11-29 04:27 UTC · original · reviewed

Reviewed head e73386f5b against the base by static inspection only. No builds, tests, or GPU runs.

  • Major · docs/linux_proton.md:104 and scripts/run_game_wine.sh:217. A warm MESA_SHADER_CACHE_DIR or __GL_SHADER_DISK_CACHE_PATH still reaches Wine under --cache fresh. The launcher prints “fresh” even though the driver can reuse that explicit cache during a cold-cache comparison. Please document that the flag selects the XDG cache root, name the driver overrides callers should unset for cold measurements, and add a stub assertion for their precedence.
  • Minor · scripts/run_game_wine.sh:217 and scripts/run_game_wine.sh:221. Fresh mode can reuse cache entries already present in an accepted output directory. Retrying a failed display startup with a different cache choice also appends a second, potentially contradictory status. Please reserve an unused directory for fresh mode or reject a pre-existing one, and write the session header anew on each launch.
  • Minor · tests/test_run_game_wine_safety.py:194. This fixture inherits XDG_CACHE_HOME. If it names a regular file, the new directory creation aborts the launcher before the fixture can verify summary exit propagation. Please add --cache fresh to the shared fixture arguments.

The new cache parsing guards unset values under set -u, and the directory operations quote paths with spaces. The shared base already uses Bash 4 case conversion for device selection. --cache takes precedence over the caller's XDG setting. The launcher passes through separate Mesa, NVIDIA, AMD, DXVK, and VKD3D cache environment variables, and the new Wine stub exercises the XDG selection.

AI-assisted.

**@⁠timbot103** on GitHub · 2026-11-29 04:27 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436#pullrequestreview-6101397674) · **reviewed** Reviewed head `e73386f5b` against the base by static inspection only. No builds, tests, or GPU runs. - **Major** · `docs/linux_proton.md:104` and `scripts/run_game_wine.sh:217`. A warm `MESA_SHADER_CACHE_DIR` or `__GL_SHADER_DISK_CACHE_PATH` still reaches Wine under `--cache fresh`. The launcher prints “fresh” even though the driver can reuse that explicit cache during a cold-cache comparison. Please document that the flag selects the XDG cache root, name the driver overrides callers should unset for cold measurements, and add a stub assertion for their precedence. - **Minor** · `scripts/run_game_wine.sh:217` and `scripts/run_game_wine.sh:221`. Fresh mode can reuse cache entries already present in an accepted output directory. Retrying a failed display startup with a different cache choice also appends a second, potentially contradictory status. Please reserve an unused directory for fresh mode or reject a pre-existing one, and write the session header anew on each launch. - **Minor** · `tests/test_run_game_wine_safety.py:194`. This fixture inherits `XDG_CACHE_HOME`. If it names a regular file, the new directory creation aborts the launcher before the fixture can verify summary exit propagation. Please add `--cache fresh` to the shared fixture arguments. The new cache parsing guards unset values under `set -u`, and the directory operations quote paths with spaces. The shared base already uses Bash 4 case conversion for device selection. `--cache` takes precedence over the caller's XDG setting. The launcher passes through separate Mesa, NVIDIA, AMD, DXVK, and VKD3D cache environment variables, and the new Wine stub exercises the XDG selection. AI-assisted.
Review follow-up (timbot103):
- A driver's own variable wins over XDG_CACHE_HOME, so a warm MESA_SHADER_CACHE_DIR, MESA_GLSL_CACHE_DIR or
  __GL_SHADER_DISK_CACHE_PATH reached Wine under --cache fresh. A fresh run now unsets them; with a kept cache the
  caller's variables stay and win. --help and docs/linux_proton.md say so.
- A run folder whose earlier launch did not start is accepted again: a fresh run now empties its session/cache, and
  session.txt is written anew instead of getting a second "shader cache:" line.
- test_run_game_wine_safety's shared fixture passes --cache fresh, so an inherited XDG_CACHE_HOME stays out.

Two new tests in tests/test_run_game_wine.py fail with the old script and pass with this one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-30 08:16 UTC · original

Thanks, all three addressed in 206bb4b6:

  • Major: --cache fresh now unsets MESA_SHADER_CACHE_DIR, MESA_GLSL_CACHE_DIR and __GL_SHADER_DISK_CACHE_PATH, so a fresh run is cold whatever the caller had set; with a kept cache the caller's variables stay and win over the XDG root. --help and docs/linux_proton.md say both. test_a_fresh_cache_drops_the_drivers_own_cache_variables checks the stub sees none of them under fresh and the caller's values under a kept cache.
  • Minor: a fresh run empties session/cache in a run folder that is accepted again, and session.txt is written anew on each launch (>), so there is one shader cache: line; test_a_fresh_cache_is_empty_in_an_accepted_run_folder.
  • Minor: the safety fixture passes --cache fresh.

Linux, Python 3.13: tests/test_run_game_wine.py 14/14 (the two new tests fail with the old script), tests/test_run_game_wine_safety.py 3/3, also with XDG_CACHE_HOME naming a regular file. Merges cleanly into main d762b139.

AI-assisted (Claude Code); I ran the tests and checked the results.


Generated by Claude Code

**@⁠kawaii-shakal** on GitHub · 2026-11-30 08:16 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7272693868) Thanks, all three addressed in 206bb4b6: - Major: `--cache fresh` now unsets `MESA_SHADER_CACHE_DIR`, `MESA_GLSL_CACHE_DIR` and `__GL_SHADER_DISK_CACHE_PATH`, so a fresh run is cold whatever the caller had set; with a kept cache the caller's variables stay and win over the XDG root. `--help` and `docs/linux_proton.md` say both. `test_a_fresh_cache_drops_the_drivers_own_cache_variables` checks the stub sees none of them under fresh and the caller's values under a kept cache. - Minor: a fresh run empties `session/cache` in a run folder that is accepted again, and `session.txt` is written anew on each launch (`>`), so there is one `shader cache:` line; `test_a_fresh_cache_is_empty_in_an_accepted_run_folder`. - Minor: the safety fixture passes `--cache fresh`. Linux, Python 3.13: `tests/test_run_game_wine.py` 14/14 (the two new tests fail with the old script), `tests/test_run_game_wine_safety.py` 3/3, also with `XDG_CACHE_HOME` naming a regular file. Merges cleanly into main d762b139. AI-assisted (Claude Code); I ran the tests and checked the results. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot referenced this pull request from a commit 2026-12-01 11:31:12 +00:00
github-bot changed target branch from main to gh-pr/2436/base 2026-12-01 11:31:48 +00:00
github manually merged commit 22d58b8629 into gh-pr/2436/base 2026-12-01 11:31:49 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-12-01 11:30 UTC · original · approved these changes

Reviewed head diff against main: scripts/run_game_wine.sh cleanly adds --cache DIR|fresh (defaulting to caller XDG_CACHE_HOME or fresh), unsets driver-specific cache overrides and clears session/cache on fresh runs, records the active cache mode in session.txt, updates docs/linux_proton.md, and adds unit test coverage in tests/test_run_game_wine.py and tests/test_run_game_wine_safety.py. Clean-room verified and all CI checks green.

(AI-assisted review.)

**@⁠aslan2142** on GitHub · 2026-12-01 11:30 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2436#pullrequestreview-6130340661) · **approved these changes** Reviewed head diff against `main`: `scripts/run_game_wine.sh` cleanly adds `--cache DIR|fresh` (defaulting to caller `XDG_CACHE_HOME` or `fresh`), unsets driver-specific cache overrides and clears `session/cache` on `fresh` runs, records the active cache mode in `session.txt`, updates `docs/linux_proton.md`, and adds unit test coverage in `tests/test_run_game_wine.py` and `tests/test_run_game_wine_safety.py`. Clean-room verified and all CI checks green. *(AI-assisted review.)*
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!2436
No description provided.