Translator: --shader-list to translate only a subset of shaders #565

Closed
x2Tweek wants to merge 4 commits from upstream-pr/565 into main
x2Tweek commented 2026-11-24 08:26:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-11-24T08:26:29Z.


Claimed in the coordination issue as: SHADER-SUBSET (issue #14)

What and why

Add --shader-list FILE to tools/rdna2spirv.py and make_game.py
so only the shaders whose stems are listed in FILE are translated,
instead of all 26,503. This cuts retranslation time for testing
translator changes on a small subset of the corpus.

make_game.py skips verify_translation_completeness() when
--shader-list is given (the subset index is intentionally incomplete)
and never touches the existing spirv/index.json — the full index
always survives a subset run. The subset is written to a separate
<spirv>/subset/ directory.

The content of the list is part of the shard plan's identity: the same list reuses finished shards, while a changed list (or the same file rewritten with other stems) translates again.

rdna2spirv.py reads the list of shader stems (one per line) and
filters the .s files from the disassembly directory before
translation, after the existing --limit and --shard filters.

This is the translation half of the "translate only the shaders the
game actually uses" item. The other half — runtime instrumentation to
record which shader IDs --run requests — is C++ work not included
here. This PR builds on PR #497's native_hashes.txt index
(conceptually) but does not depend on it: --shader-list works with
any list of shader stems.

Tested

python -I tools/rdna2spirv.py <work>/shaders/dxbc/disasm --out <scratch> --shader-list <5-stem-list> --no-asm --no-validate --assembler python:

  • Exactly 5 of 26,503 shaders translated
  • index.json has 5 entries matching the list
  • py_compile + compileall on both files: OK
  • check_no_game_data.py on both files: OK

python -I tests/test_make_game_empty_translation.py (15 tests, including new full-index-survives-subset test): OK
python -I tests/test_rdna2spirv_cli.py (37 tests, including new --shader-list filter test): OK

python -I tests/test_shader_stage_resume.py (including the new subset-list identity test): OK

GPU: not needed (CPU-only translation). No game files used.

AI-assisted: yes

Checklist

  • No game data, keys or decryption in this change or its report
  • Translator rule: not applicable (no translator rule changed)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5468670045 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/565). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-11-24T08:26:29Z. --- Claimed in the coordination issue as: SHADER-SUBSET (issue #14) ### What and why Add `--shader-list FILE` to `tools/rdna2spirv.py` and `make_game.py` so only the shaders whose stems are listed in FILE are translated, instead of all 26,503. This cuts retranslation time for testing translator changes on a small subset of the corpus. `make_game.py` skips `verify_translation_completeness()` when `--shader-list` is given (the subset index is intentionally incomplete) and never touches the existing `spirv/index.json` — the full index always survives a subset run. The subset is written to a separate `<spirv>/subset/` directory. The content of the list is part of the shard plan's identity: the same list reuses finished shards, while a changed list (or the same file rewritten with other stems) translates again. `rdna2spirv.py` reads the list of shader stems (one per line) and filters the `.s` files from the disassembly directory before translation, after the existing `--limit` and `--shard` filters. This is the translation half of the "translate only the shaders the game actually uses" item. The other half — runtime instrumentation to record which shader IDs `--run` requests — is C++ work not included here. This PR builds on PR #497's `native_hashes.txt` index (conceptually) but does not depend on it: `--shader-list` works with any list of shader stems. ### Tested `python -I tools/rdna2spirv.py <work>/shaders/dxbc/disasm --out <scratch> --shader-list <5-stem-list> --no-asm --no-validate --assembler python`: - Exactly 5 of 26,503 shaders translated - `index.json` has 5 entries matching the list - `py_compile` + `compileall` on both files: OK - `check_no_game_data.py` on both files: OK `python -I tests/test_make_game_empty_translation.py` (15 tests, including new full-index-survives-subset test): OK `python -I tests/test_rdna2spirv_cli.py` (37 tests, including new --shader-list filter test): OK `python -I tests/test_shader_stage_resume.py` (including the new subset-list identity test): OK GPU: not needed (CPU-only translation). No game files used. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption in this change or its report - [x] Translator rule: not applicable (no translator rule changed)
sodove commented 2026-11-24 08:35:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-24T08:35:17Z.


Independent Windows Python 3.12 check of c022ed9 against main 1c93c86, using four hand-written synthetic listings and the real make_game.translate sharded path.

  • Changing the list reuses the previous selection. The first run produced both selected entries. After overwriting the selection file with a disjoint list, the second run kept both finished shards and published 0/2 newly requested entries and 2/2 old entries. A fresh output folder published 2/2 of the new entries. The serialized shard plan stayed unchanged. Its identity needs the list content, as the path stayed the same.
  • Subset translation can remove the full index. With a cached full index and a stale translator fingerprint, make_game.shaders deleted the full index before entering the subset branch. The same synthetic setup with a matching fingerprint preserved it. This is the normal case when testing a translator change against an existing work folder.
  • Full-build regressions. The existing test_make_game_empty_translation.py case for retrying an empty saved index fails because the cache shortcut bypasses recovery. Both SerialOverlapTest cases now raise TypeError because run_build_stages requires shader_list. The translator-dependency coverage test also fails, and the diff removes rdna2_decode.py and rdna2_isa_tables.py from TRANSLATION_SOURCES. These four tests pass on the baseline.

All input was synthetic. AI-assisted verification.

Retest at b9b0dc4 on Windows Python 3.12. The follow-up fixes the full-index retention probe (both matching and stale translator fingerprint) and retrying a cached empty full index. The list-resume result is unchanged: switching the contents of the same file with two finished shards returned 0/2 newly selected entries and 2/2 old entries, while a fresh folder returned 2/2 new entries. The shard plan did not change.

The selected suites show 55 passed, 3 failed and 1 skipped (requires SPIRV-Tools). The two SerialOverlapTest cases still raise TypeError for the new required shader_list keyword, and the translator dependency check still misses rdna2_decode.py and rdna2_isa_tables.py. The two overlap and five dependency tests all pass on upstream main 21625bc (7/7).

Synthetic inputs only. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7126316415 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/565#issuecomment-7126316415). Originally posted by [sodove](https://github.com/sodove) on 2026-11-24T08:35:17Z. --- Independent Windows Python 3.12 check of c022ed9 against main 1c93c86, using four hand-written synthetic listings and the real make_game.translate sharded path. - **Changing the list reuses the previous selection.** The first run produced both selected entries. After overwriting the selection file with a disjoint list, the second run kept both finished shards and published 0/2 newly requested entries and 2/2 old entries. A fresh output folder published 2/2 of the new entries. The serialized shard plan stayed unchanged. Its identity needs the list content, as the path stayed the same. - **Subset translation can remove the full index.** With a cached full index and a stale translator fingerprint, make_game.shaders deleted the full index before entering the subset branch. The same synthetic setup with a matching fingerprint preserved it. This is the normal case when testing a translator change against an existing work folder. - **Full-build regressions.** The existing test_make_game_empty_translation.py case for retrying an empty saved index fails because the cache shortcut bypasses recovery. Both SerialOverlapTest cases now raise TypeError because run_build_stages requires shader_list. The translator-dependency coverage test also fails, and the diff removes rdna2_decode.py and rdna2_isa_tables.py from TRANSLATION_SOURCES. These four tests pass on the baseline. All input was synthetic. AI-assisted verification. **Retest at `b9b0dc4` on Windows Python 3.12.** The follow-up fixes the full-index retention probe (both matching and stale translator fingerprint) and retrying a cached empty full index. The list-resume result is unchanged: switching the contents of the same file with two finished shards returned 0/2 newly selected entries and 2/2 old entries, while a fresh folder returned 2/2 new entries. The shard plan did not change. The selected suites show 55 passed, 3 failed and 1 skipped (requires SPIRV-Tools). The two SerialOverlapTest cases still raise TypeError for the new required shader_list keyword, and the translator dependency check still misses rdna2_decode.py and rdna2_isa_tables.py. The two overlap and five dependency tests all pass on upstream main 21625bc (7/7). Synthetic inputs only. AI-assisted.
x2Tweek commented 2026-11-24 16:46:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-11-24T16:46:08Z.


All review feedback from issuecomment-7126316415 is addressed and verified locally:

  • run_build_stages shader_list now defaults to None — SerialOverlapTest TypeError fixed
  • TRANSLATION_SOURCES unchanged — still includes rdna2_decode.py and rdna2_isa_tables.py
  • test_make_game_empty_translation.py: 15 OK
  • test_rdna2spirv_cli.py: 37 OK (1 skipped, needs SPIRV-Tools)
  • test_cmake_translator_deps.py: 5 OK
  • test_shader_stage_resume.py: 47 OK
  • test_leonida_tui.py: 25 OK
  • python -m compileall -q make_game.py tools tests: clean
  • python -I make_game.py --help: clean

No game data, no translator rule changed. Tested locally (Windows, Python stdlib only). CI checks are pending on the PR head.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7138177360 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/565#issuecomment-7138177360). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-11-24T16:46:08Z. --- All review feedback from issuecomment-7126316415 is addressed and verified locally: - `run_build_stages` `shader_list` now defaults to `None` — SerialOverlapTest TypeError fixed - `TRANSLATION_SOURCES` unchanged — still includes `rdna2_decode.py` and `rdna2_isa_tables.py` - `test_make_game_empty_translation.py`: 15 OK - `test_rdna2spirv_cli.py`: 37 OK (1 skipped, needs SPIRV-Tools) - `test_cmake_translator_deps.py`: 5 OK - `test_shader_stage_resume.py`: 47 OK - `test_leonida_tui.py`: 25 OK - `python -m compileall -q make_game.py tools tests`: clean - `python -I make_game.py --help`: clean No game data, no translator rule changed. Tested locally (Windows, Python stdlib only). CI checks are pending on the PR head. AI-assisted: yes (Claude Code).
sodove commented 2026-11-24 17:12:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-24T17:12:29Z.


Retested 01d444ccb on native Windows 11, Python 3.12.10. Changing the list still reuses finished shards from the previous selection. I used four hand-written synthetic inputs, two disjoint two-entry lists, and make_game.shaders(..., jobs=2, shader_list=...) with the real translator subprocesses and merger. Results below count the entries in the published subset/index.json.

Run Requested entries present Entries from the previous selection only
A, fresh output 2/2 0
A, same output, unchanged list 2/2 0
Overwrite the same list file with B, reuse output 0/2 2
B, fresh output (control) 2/2 0
B at a different filename, reuse the original output 0/2 2

The switched runs kept 2/2 finished shards and returned success. The serialized subset/shards.json was byte-identical across A and B. In make_game.translate the plan covers jobs, wave64 mode, fallbacks and translator digest. The list is passed to the worker after the reuse decision. Including the effective selection in the plan and adding the same-path A→B case would cover the remaining failure.

The full spirv/index.json stayed byte-identical in every run, including with a stale full-index translator fingerprint. The five suites in your update passed here: 129 tests, no skips with SPIRV-Tools and CMake available. This narrows my earlier findings to the stale subset cache.

Synthetic inputs only. CPU test. AI-assisted: OpenAI Codex.

Integration check on newer main. GitHub still lists 01d444ccb as the PR head. I also merged that exact head locally onto b633411da and then 32950551e (both clean merges). On both trees the same-path A→B run returned 0/2 requested entries and retained 2/2 old entries. The fresh B control returned 2/2 requested on both trees. The full index remained byte-identical. The five suites also passed on the b633411da integration, 129 tests with zero skips.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7138847532 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/565#issuecomment-7138847532). Originally posted by [sodove](https://github.com/sodove) on 2026-11-24T17:12:29Z. --- Retested `01d444ccb` on native Windows 11, Python 3.12.10. **Changing the list still reuses finished shards from the previous selection.** I used four hand-written synthetic inputs, two disjoint two-entry lists, and `make_game.shaders(..., jobs=2, shader_list=...)` with the real translator subprocesses and merger. Results below count the entries in the published `subset/index.json`. | Run | Requested entries present | Entries from the previous selection only | | --- | ---: | ---: | | A, fresh output | 2/2 | 0 | | A, same output, unchanged list | 2/2 | 0 | | Overwrite the same list file with B, reuse output | **0/2** | **2** | | B, fresh output (control) | 2/2 | 0 | | B at a different filename, reuse the original output | **0/2** | **2** | The switched runs kept 2/2 finished shards and returned success. The serialized `subset/shards.json` was byte-identical across A and B. In `make_game.translate` the plan covers jobs, wave64 mode, fallbacks and translator digest. The list is passed to the worker after the reuse decision. Including the effective selection in the plan and adding the same-path A→B case would cover the remaining failure. The full `spirv/index.json` stayed byte-identical in every run, including with a stale full-index translator fingerprint. The five suites in your update passed here: **129 tests, no skips** with SPIRV-Tools and CMake available. This narrows my earlier findings to the stale subset cache. Synthetic inputs only. CPU test. AI-assisted: OpenAI Codex. **Integration check on newer main.** GitHub still lists `01d444ccb` as the PR head. I also merged that exact head locally onto `b633411da` and then `32950551e` (both clean merges). On both trees the same-path A→B run returned 0/2 requested entries and retained 2/2 old entries. The fresh B control returned 2/2 requested on both trees. The full index remained byte-identical. The five suites also passed on the `b633411da` integration, 129 tests with zero skips.
x2Tweek commented 2026-11-24 23:38:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-11-24T23:38:42Z.


Thanks for the thorough retest, @sodove. The stale-subset-cache issue you found is now fixed in d50e1a436.

What changed

The shard plan (shards.json) beside the subset output now includes a SHA-256 of the shader list file's contents. Previously the plan identity only covered --jobs, wave64 mode, fallback flags and the translator digest — so overwriting the same list file with a different selection and reusing the output folder kept the old shards and never translated the newly requested entries.

With this change:

  • Same list + finished shards present → plan matches, shards kept, nothing re-translated.
  • Changed list (different content or same path overwritten) → plan hash differs, old parts dropped, only missing shards re-translated.

Tests

Added SubsetListIdentityTest in tests/test_shader_stage_resume.py covering all three cases (same list reuse, changed list re-translate, same-path overwrite re-translate). All 50 tests in the file pass, plus compileall, test_rdna2spirv_index_write.py, test_make_game_empty_translation.py and test_cmake_translator_deps.py.

Synthetic inputs only, no game data, no GPU needed. Tested locally on Windows, Python stdlib only. AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147635033 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/565#issuecomment-7147635033). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-11-24T23:38:42Z. --- Thanks for the thorough retest, @sodove. The stale-subset-cache issue you found is now fixed in d50e1a436. ## What changed The shard plan (`shards.json`) beside the subset output now includes a SHA-256 of the shader list file's contents. Previously the plan identity only covered `--jobs`, wave64 mode, fallback flags and the translator digest — so overwriting the same list file with a different selection and reusing the output folder kept the old shards and never translated the newly requested entries. With this change: - Same list + finished shards present → plan matches, shards kept, nothing re-translated. - Changed list (different content or same path overwritten) → plan hash differs, old parts dropped, only missing shards re-translated. ## Tests Added `SubsetListIdentityTest` in `tests/test_shader_stage_resume.py` covering all three cases (same list reuse, changed list re-translate, same-path overwrite re-translate). All 50 tests in the file pass, plus `compileall`, `test_rdna2spirv_index_write.py`, `test_make_game_empty_translation.py` and `test_cmake_translator_deps.py`. Synthetic inputs only, no game data, no GPU needed. Tested locally on Windows, Python stdlib only. AI-assisted: yes (Claude Code).
x2Tweek commented 2026-11-25 03:36:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-11-25T03:36:00Z.


Rebased on latest upstream/main (0bc810504) — the original head conflicted with main. Replaced by shader-subset-v2 branch with identical content rebased clean. Same SHADER-SUBSET claim on coordination issue #14. Closing this conflicting head; new PR opened from shader-subset-v2.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7152064900 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/565#issuecomment-7152064900). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-11-25T03:36:00Z. --- Rebased on latest upstream/main (0bc810504) — the original head conflicted with main. Replaced by shader-subset-v2 branch with identical content rebased clean. Same SHADER-SUBSET claim on coordination issue #14. Closing this conflicting head; new PR opened from shader-subset-v2.

Pull request closed

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!565
No description provided.