Skip to content

make_game: refuse a translation index that lost carved shaders - #4582

Open
abilliontokens wants to merge 1 commit into
ItsNotRexed:mainfrom
abilliontokens:fh-translation-completeness
Open

abilliontokens wants to merge 1 commit into
ItsNotRexed:mainfrom
abilliontokens:fh-translation-completeness

Conversation

@abilliontokens

Copy link
Copy Markdown
Contributor

New BUILD item, claimed in #4257.

What and why

rdna2spirv.py drops a shader that is refused or whose module fails spirv-val (the module never reaches the
final path) and still exits 0, and nothing later in the build compares counts. Measured on a full end-to-end
make_game.py run at aa2988cc (own 1.0.2.1 copy, --wave64-emulate, 6 jobs): 26,503 carved, 26,503
translated, but the merged spirv/index.json held 26,473 — 30 modules had failed spirv-val (the aa2988cc
typed-buffer regression; per-shard deltas 5/5/7/5/1/7) — and the stage printed shaders: done, finished in 124 min, exit 0. A port assembled from that index silently lacks the dropped shaders.

The shaders stage now verifies the merged index against the carve and fails naming the gap, the same way the
disassembly step already refuses an incomplete listing set. Scope kept deliberately narrow:

This PR has no Depends on: but will fail builds loudly until a translator fix like #3902 lands for the current
regression class — intended: the alternative is a port missing shaders with no signal.

Tested

Windows 11, Python 3.12 (python -I), commit 118e3933 on main 03b09a08:

  • tests/test_make_game_translation_completeness.py — 5/5 OK. On unmodified main the same file errors 4/4
    (the function does not exist); the defect itself is the run above: --stages shaders exited 0 at aa2988cc
    with 26,473 of 26,503.
  • Real-work-folder verification: with this change, --stages shaders on the completed run's work folder exits 1
    with the translation index holds 26473 of the 26503 carved shaders (30 were refused or failed spirv-val…).
  • Neighbours: test_make_game_dry_run, test_make_game_resume, test_make_game_translate_cleanup,
    test_make_game_wave64, test_make_game_translator_flags, test_make_game_pipeline_preflight,
    test_make_game_platform, test_make_game_paths, test_make_game_argparse, test_make_game_interrupt,
    test_make_game_destinations, test_make_game_container, test_make_game_pick, test_make_game_submodule,
    test_make_game_assets_decoder, test_make_game_assets_pools, test_make_game_python_version — all OK.
  • python -m compileall -q make_game.py tests/test_make_game_translation_completeness.py.

Checklist

  • No game data, keys or decryption, including in logs or reports (counts and exit codes only).

AI-assisted (omp orchestrator).

rdna2spirv.py drops a shader that is refused or whose module fails
spirv-val and still exits 0, so a full run can carve 26,503 shaders and
finish done with an index of 26,473 (measured end to end at aa2988c,
--wave64-emulate, 6 jobs): a port built from it silently lacks the rest.
The shaders stage now compares the merged index with the carve and fails
naming the gap, the way the disassembly step already refuses an
incomplete listing set. An empty index stays ItsNotRexed#3328's, a missing one
stays with the merge and translate failures that own it.
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 118e393 on Windows, CPython 3.14.7, CPU only (no GPU, no game files). All files below are synthetic.

The new suite passes 5 of 5 tests, and the existing shader-stage resume suite passes 44 of 44.

One case stays. A stale entry can hide a missing shader: the stage accepts a translation index that has the correct number of entries but the wrong shader name.

python -I -c "import pathlib,runpy; case=runpy.run_path('tests/test_shader_stage_resume.py')['ShaderStageResumeTest'](); case.setUp(); case.run_stage(); p=pathlib.Path(case.spirv,'index.json'); p.write_text('{\u0022unrelated\u0022:{}}',encoding='utf8'); print(case.run_stage()); case.tearDown(); case.doCleanups()"

The fixture carves s0.dxbc. The saved translation index then contains only unrelated.
Actual result: the second call returns [], and the stage succeeds.
Expected result: the stage reports that s0 is missing.

The new guard corrects the case where the counts differ, but not this case where the counts are equal. The merge base also accepts this index.
Possible correction: compare the stems of the carved file names with the keys of the translation index. This also covers the names that the carver changes to prevent collisions.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

PASS, with two issues worth deciding on.

Verified at the head: the new suite 5/5, all 19 neighbouring tests/test_make_game_*.py pass, compileall and check_no_game_data clean, git diff --check clean, merge clean. Negative control: this test file against main's make_game.py errors 5 times (no attribute 'verify_translation_completeness').

  • The equality is measured against the carve index, but this file deliberately tolerates carved containers that never yield a listing (tools/fssm_unpack.py:172-177 skips parse failures / no XBCH), and disassembly_status only demands listings <= active (make_game.py:882-890). Such a gap would be reported as "refused or failed spirv-val" (:1411-1413) and block an otherwise healthy build. The shipped corpus is 26,503/26,503 XBCH (docs/fssm_crosscheck.md:38), so it is latent, not observed - but the check should distinguish "carved but not listing" from "translation lost it".
  • A present-but-unparseable spirv/index.json returns silently (:1399-1403); on a resumed stage translate() is skipped, so nothing else ever reads it.

Style nit: one blank line before the section header at :1414-1415 where main had two.

AI-assisted review, no game files, no GPU.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 118e393 merged with main d0835dd (merge 063158de8, no conflicts) on Linux (WSL2) Python 3.12.16 and native Windows 11 Python 3.13.1: concern (works as described; behaviour change to decide).

  • tests/test_make_game_translation_completeness.py: 5/5 OK on both. Negative control: make_game.py from main, same tests: 5 errors (no verify_translation_completeness) on Linux and on Windows.
  • Concern: the test's own docstring records a real run at aa2988c with 26,503 carved and 26,473 indexed shaders and exit 0. With this check the shaders stage now stops with fail(...) on that corpus, so every full run of make_game.py fails at the end of shaders until the 30 refused shaders are translated (and index.json is already published by then, so a re-run goes through fail again rather than passing). That fits "fix, don't skip" in AGENTS.md, but it turns a silent loss into a hard stop for anyone building today; worth the maintainers deciding, or a flag for the old behaviour.
  • Read the diff: an unreadable index or an empty one returns quietly (the PR says other code owns those cases); a non-object translation index or a non-list carve index fails.

@whattheflop whattheflop 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.

AI-assisted Windows CPU check at 118e3933 and parent 03b09a08, uv CPython 3.12.13. The synthetic fixture used real carve/unpack/translate tools and hand-written disassembly. It produced three DXBC translation entries from two native hashes. Case-colliding aliases kept distinct keys, and FSPX used its separate index. I found no path in the normal build for either to inflate the DXBC count.

A separate resume case has an intact, nonempty index naming exactly all three carved shaders, but one previously validated .spv is missing. With every resume marker unchanged, both revisions treated the DXBC cache as reusable, launched zero shader tools, and printed shaders: done. The file stayed missing. The real FSPX cache check rebuilt its module after equivalent file loss. This is a pre-existing DXBC resume gap outside the new count check and distinct from the equal-cardinality wrong-name case and #3328's empty-index recovery. The five stock completeness tests passed at head.

@whattheflop whattheflop 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.

Follow-up to the missing-module report: #3665 (BUILD-1056) already handles that gap. AI-assisted Windows CPU check with uv CPython 3.12.13 at #3665 797ea022 plus #4582 118e3933. Both merge cleanly onto d0835dd9 (combined tree 59247095).

The real make_game.translate path translated nine synthetic listings in three shards with SPIRV-Tools. After deleting one output in shard 0, the cache inventory refused the hit. The retry rebuilt shard 0, reused shards 1 and 2 without rewriting their markers or part indexes, and restored the nine-entry merged index. This PR's count check then accepted nine carved entries, and separately reported 9 of 10 when the carve count exceeded the translated count. The test exercised the translation and check functions directly, bypassing the earlier carve/disassembly stages. Five focused suites passed 94 tests in the combined tree.

@Kam471 Kam471 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.

Ran this at 118e3933 on Windows 11: pytest tests/test_make_game_translation_completeness.py tests/test_make_game_preflight.py -q -> 83 passed, 1 skipped, 27 subtests passed; git diff --check clean.

verify_translation_completeness runs after the translate block in the shaders stage, so it also covers an incremental run that skips translation. It compares the carve index list length with the merged translation index object length and fails naming the gap; missing/unreadable files and an empty index return early (owned by the translate and #3328 paths). The new tests cover the short index, the equal index and the unreadable cases. No blocking issue.

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.

6 participants