Skip to content

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

Open
x2Tweek wants to merge 5 commits into
ProjectLeonida:mainfrom
x2Tweek:shader-subset-v2
Open

x2Tweek wants to merge 5 commits into
ProjectLeonida:mainfrom
x2Tweek:shader-subset-v2

Conversation

@x2Tweek

@x2Tweek x2Tweek commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

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 0bc8105.

  • 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 Translator: --shader-list to translate only a subset of shaders #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 and others added 4 commits November 25, 2026 04:27
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 <noreply@anthropic.com>
…s full index

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@GeorgiyDemo

Copy link
Copy Markdown
Contributor

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.

@sodove

sodove commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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).

@tiguan26 tiguan26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@x2Tweek

x2Tweek commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

@tiguan26 tiguan26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants