Translator: --shader-list to translate only a subset of shaders (SHADER-SUBSET) #1529

Open
github-bot wants to merge 5 commits from github-bot/gh-1529 into main AGit
Owner

@⁠x2Tweek on GitHub · 2026-11-25 03:36 UTC · original
x2Tweek:shader-subset-v2 → main · +269 −71 · 5 files · 5 commits · open

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

What and why

Translator: --shader-list to translate only a subset of shaders. Replaces closed PR #565 whose head conflicted with upstream/main. Rebased on upstream main at 0bc810504.

  • tools/rdna2spirv.py --shader-list FILE and make_game.py --shader-list FILE: subset writes to <spirv>/subset/, never touches the full spirv/index.json, skips fingerprint checks and verify_translation_completeness.
  • The shard plan beside the subset output now includes a SHA-256 of the shader list file's contents, so overwriting the same list file with a different selection drops old parts and re-translates only missing shards (fixes the stale-subset-cache bug reported by sodove on #565).
  • 3 new SubsetListIdentityTest cases in tests/test_shader_stage_resume.py cover same-list reuse, changed-list re-translate, and same-path overwrite re-translate.

Tested

  • tests/test_shader_stage_resume.py: 50 passed (3 new SubsetListIdentityTest cases)
  • tests/test_rdna2spirv_index_write.py: 8 passed, 1 skipped (9 total)
  • tests/test_make_game_empty_translation.py: 16 passed
  • tests/test_rdna2spirv_cli.py: 37 passed
  • python -m compileall -q make_game.py tools tests: clean
  • python -I make_game.py --help: clean
  • All synthetic inputs, no game data, no GPU needed. Tested locally on Windows, Python stdlib only.

GPUs tested: n/a

AI-assisted: yes (Claude Code)

Checklist:

  • No game data, keys or decryption
  • Translator rule in the contract table in docs/design.md (N/A — no new translator rule)
  • Tested on local Windows machine (Python 3.15.2, stdlib only)
**@⁠x2Tweek** on GitHub · 2026-11-25 03:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1529) `x2Tweek:shader-subset-v2` → `main` · +269 −71 · 5 files · 5 commits · open Claimed in the coordination issue as: SHADER-SUBSET (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Translator: `--shader-list` to translate only a subset of shaders. Replaces closed PR #565 whose head conflicted with upstream/main. Rebased on upstream main at 0bc810504. - `tools/rdna2spirv.py --shader-list FILE` and `make_game.py --shader-list FILE`: subset writes to `<spirv>/subset/`, never touches the full `spirv/index.json`, skips fingerprint checks and `verify_translation_completeness`. - The shard plan beside the subset output now includes a SHA-256 of the shader list file's contents, so overwriting the same list file with a different selection drops old parts and re-translates only missing shards (fixes the stale-subset-cache bug reported by sodove on #565). - 3 new `SubsetListIdentityTest` cases in `tests/test_shader_stage_resume.py` cover same-list reuse, changed-list re-translate, and same-path overwrite re-translate. ### Tested - `tests/test_shader_stage_resume.py`: 50 passed (3 new SubsetListIdentityTest cases) - `tests/test_rdna2spirv_index_write.py`: 8 passed, 1 skipped (9 total) - `tests/test_make_game_empty_translation.py`: 16 passed - `tests/test_rdna2spirv_cli.py`: 37 passed - `python -m compileall -q make_game.py tools tests`: clean - `python -I make_game.py --help`: clean - All synthetic inputs, no game data, no GPU needed. Tested locally on Windows, Python stdlib only. GPUs tested: n/a AI-assisted: yes (Claude Code) Checklist: - [x] No game data, keys or decryption - [x] Translator rule in the contract table in docs/design.md (N/A — no new translator rule) - [x] Tested on local Windows machine (Python 3.15.2, stdlib only)
Add --shader-list FILE to 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 drops any
previous full index before re-translating.

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.

Tested on a 5-shader subset: exactly 5 translated, index.json has 5
entries. No game data, no translator rule changed.

Co-Authored-By: Claude Code <[email protected]>
When --shader-list is given, write the subset translation to
<spirv>/subset/ instead of the main <spirv>/ directory. Never drop or
overwrite the existing full index.json. The full index always survives
a subset translation run.

verify_translation_completeness() is only called for full translations.

Co-Authored-By: Claude Code <[email protected]>
When --shader-list is given, write the subset to <spirv>/subset/ and
skip all full-index fingerprint checks (translator digest, wave64
mode, fallback flags). The existing spirv/index.json is never read,
dropped, or overwritten by a subset run. Carving/unpacking/disassembly
no longer drop the full index when a subset is requested.

Adds tests:
- tests/test_make_game_empty_translation.py: full index survives a
  subset translation run; translate() is called with the subset dir
  and the shader list.
- tests/test_rdna2spirv_cli.py: --shader-list filters .s files by stem,
  only listed shaders are translated and indexed.

Co-Authored-By: Claude Code <[email protected]>
When --shader-list is used, the shard plan (shards.json) did not hash the
list file's contents, so overwriting the same list with a different
selection and reusing the output folder kept the old shards instead of
re-translating the newly requested entries. Add a sha256 of the list
contents to the plan so a changed list is detected as a plan mismatch,
dropping the old parts and starting only the missing shards.

Adds SubsetListIdentityTest covering: same list reuses finished shards,
changed list re-translates, and overwriting the same file path with new
content re-translates.

Co-Authored-By: Claude Code <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:55:29 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 03:51 UTC · original

Tested c3d151561 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 5129be10d (translator / make_game.py CLI; no GPU):

  • pytest 9.2.0 (from tests/requirements.txt) on tests/test_rdna2spirv_cli.py tests/test_make_game_empty_translation.py tests/test_shader_stage_resume.py: 101 passed, 1 skipped, 38 subtests passed at this head.
  • The same three files on main: 5 failed, 96 passed, 1 skipped, 38 subtests — test_shader_list_filters_translated_shaders, test_subset_translates_to_subset_dir_and_full_index_survives, and the three SubsetListIdentityTest resume/identity tests. So the subset behaviour is genuinely new coverage.
  • Not run: a real corpus translation with --shader-list (needs game data); only the synthetic tests.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 03:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1529#issuecomment-7152298314) Tested `c3d151561` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `5129be10d` (translator / `make_game.py` CLI; no GPU): - pytest 9.2.0 (from `tests/requirements.txt`) on `tests/test_rdna2spirv_cli.py tests/test_make_game_empty_translation.py tests/test_shader_stage_resume.py`: **101 passed, 1 skipped, 38 subtests passed** at this head. - The same three files on `main`: **5 failed**, 96 passed, 1 skipped, 38 subtests — `test_shader_list_filters_translated_shaders`, `test_subset_translates_to_subset_dir_and_full_index_survives`, and the three `SubsetListIdentityTest` resume/identity tests. So the subset behaviour is genuinely new coverage. - Not run: a real corpus translation with `--shader-list` (needs game data); only the synthetic tests. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠sodove on GitHub · 2026-11-25 04:35 UTC · original

Confirmed the stale subset cache I reported in #565 is fixed at c3d151561 on native Windows 11, Python 3.12.10. I reran the original case through make_game.shaders with two translator subprocesses and the real index merger, using four hand-written synthetic inputs.

Run Requested entries in published index Unrequested entries Finished shards reused
A, fresh output 2/2 0 0/2
A again, same output 2/2 0 2/2
Overwrite the same list file with disjoint B, same output 2/2 0 0/2
B, fresh output (control) 2/2 0 0/2
B under a different filename, same contents and output 2/2 0 2/2

On the old head the overwrite row returned 0/2 requested and retained both A entries. The full index stayed byte-identical in all five runs with a stale full-index translator fingerprint. The three SubsetListIdentityTest cases also passed.

CPU only. Synthetic inputs only. AI-assisted verification (OpenAI Codex).

**@⁠sodove** on GitHub · 2026-11-25 04:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1529#issuecomment-7152983346) Confirmed the stale subset cache I reported in #565 is fixed at `c3d151561` on native Windows 11, Python 3.12.10. I reran the original case through `make_game.shaders` with two translator subprocesses and the real index merger, using four hand-written synthetic inputs. | Run | Requested entries in published index | Unrequested entries | Finished shards reused | | --- | ---: | ---: | ---: | | A, fresh output | 2/2 | 0 | 0/2 | | A again, same output | 2/2 | 0 | 2/2 | | Overwrite the same list file with disjoint B, same output | 2/2 | 0 | 0/2 | | B, fresh output (control) | 2/2 | 0 | 0/2 | | B under a different filename, same contents and output | 2/2 | 0 | 2/2 | On the old head the overwrite row returned 0/2 requested and retained both A entries. The full index stayed byte-identical in all five runs with a stale full-index translator fingerprint. The three `SubsetListIdentityTest` cases also passed. CPU only. Synthetic inputs only. AI-assisted verification (OpenAI Codex).
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 05:52 UTC · original · approved these changes

Approving. Merged into current main (42537e7) with no conflicts, Linux, Python 3.13. test_make_game_empty_translation.py, test_rdna2spirv_cli.py (37 tests) and test_shader_stage_resume.py pass, and the full translator suite gives 487 files / 6,279 tests with only test_int32_to_f64 failing, the same spirv-opt crash as on main here. --shader-list filters by stem and its content is part of the shard plan identity, so a subset run cannot resume another list's plan.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 05:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1529#pullrequestreview-6052516890) · **approved these changes** Approving. Merged into current main (42537e7) with no conflicts, Linux, Python 3.13. `test_make_game_empty_translation.py`, `test_rdna2spirv_cli.py` (37 tests) and `test_shader_stage_resume.py` pass, and the full translator suite gives 487 files / 6,279 tests with only `test_int32_to_f64` failing, the same spirv-opt crash as on main here. `--shader-list` filters by stem and its content is part of the shard plan identity, so a subset run cannot resume another list's plan. AI-assisted (Claude).
Author
Owner

@⁠x2Tweek on GitHub · 2026-11-25 08:50 UTC · original

The rebase dropped the full build's early spirv-opt check for --compact-spirv. The follow-up restores it and adds a regression test that fails on the published head. The four targeted suites passed locally on Windows (111 passed, one skipped). AI-assisted: yes.

**@⁠x2Tweek** on GitHub · 2026-11-25 08:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1529#issuecomment-7157530695) The rebase dropped the full build's early spirv-opt check for --compact-spirv. The follow-up restores it and adds a regression test that fails on the published head. The four targeted suites passed locally on Windows (111 passed, one skipped). AI-assisted: yes.
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 18:47 UTC · original · approved these changes

Rechecked e89c291 and approving again. Merged into current main (b9320a1) with no conflicts. tests/test_make_game_empty_translation.py, tests/test_rdna2spirv_cli.py and tests/test_shader_stage_resume.py pass (102 passed, 1 skipped), and the full translator suite gives 490 files / 6,292 tests with only test_int32_to_f64 failing, the same baseline failure as main here (Linux, Python 3.13).

The restored need("spirv-opt") sits before the full translation starts, next to the spirv-as/spirv-val checks, so a missing spirv-opt under --compact-spirv stops the run before any index is written. The new test checks exactly that.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 18:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1529#pullrequestreview-6063154963) · **approved these changes** Rechecked e89c291 and approving again. Merged into current main (b9320a1) with no conflicts. `tests/test_make_game_empty_translation.py`, `tests/test_rdna2spirv_cli.py` and `tests/test_shader_stage_resume.py` pass (102 passed, 1 skipped), and the full translator suite gives 490 files / 6,292 tests with only `test_int32_to_f64` failing, the same baseline failure as main here (Linux, Python 3.13). The restored `need("spirv-opt")` sits before the full translation starts, next to the spirv-as/spirv-val checks, so a missing spirv-opt under `--compact-spirv` stops the run before any index is written. The new test checks exactly that. AI-assisted (Claude).
This pull request can be merged automatically.
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/1529/head:github-bot/gh-1529'
git switch 'github-bot/gh-1529'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1529'
git switch 'github-bot/gh-1529'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1529'
git switch 'github-bot/gh-1529'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1529'
git switch 'main'
git merge --squash 'github-bot/gh-1529'
git switch 'main'
git merge --ff-only 'github-bot/gh-1529'
git switch 'main'
git merge 'github-bot/gh-1529'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.