[PR #2231] tools: chain_check.py, one page of counts for the whole shader chain (TOOL-CHAIN-CHECK) #2234

Open
opened 2026-11-26 21:20:30 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2231
Author: @MoonEyes
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: tools/chain-check


📝 Commits (4)

  • d41d6a1 tools: chain_check.py, one page of counts for the whole shader chain (TOOL-CHAIN-CHECK)
  • 044e271 chain_check: close the free-text filters and pin the runtime lines it reads
  • a6ec8f3 chain_check: pin an unknown interface, a non-builtin exception and the slot-57 line
  • 1b1fb2d Merge remote-tracking branch 'origin/main' into tools/chain-check

📊 Changes

3 files changed (+1213 additions, -0 deletions)

View changed files

📝 docs/dev-tools.md (+33 -0)
➕ tests/test_chain_check.py (+405 -0)
➕ tools/chain_check.py (+775 -0)

📄 Description

Claimed in the coordination issue as: TOOL-CHAIN-CHECK

What and why

The shader chain (game files → llvm-mc → translator → SPIR-V → runtime pipelines) fails quietly link by link. On one Windows machine, llvm-mc 21.1.8 left 840 of the 2,684 compute programs of the pipeline library untranslated (839 "fall-through into undecodable words", 1 s_sethalt; #1923 measures the same gap). At boot the runtime then logged 843 slot 67 ... failed with 0x80070057 lines. Today nothing connects those two counts: the build prints no "N of M" for the library, and boot.ps1's digest shows neither slot failures nor failed CreatePipelineState calls.

tools/chain_check.py prints one page with one block per link, each with OK / WARN / FAIL and its most likely cause, then the weakest link:

  • tools: the llvm-mc each family was disassembled with (disasm.done, <family>_build.json) and its AMDGPU target, spirv-val, and the recorded translator digest against the same digest recomputed from make_game.py's TRANSLATION_SOURCES (a test pins it equal to translation_sources_digest());
  • per family (game, library, FSPX, BVH, exe): unpacked, listings, listings with rejected words (invalid_words), translated (index entries with their .spv), up to 5 refusal reasons from logs/shaders.log;
  • contract: tagged vs plain modules (#2098) and which of the runtime's folders exist (fspx_compute...);
  • runtime, from --log: modules loaded, failed slot calls by slot and HRESULT, failed D3D12 calls, compute builds, compile-gate waits, device faults, exit code.

Counts and fixed words only. A refusal reason is printed only when it matches a message rdna2spirv.py raises (read from its source), with a variable part kept only when it is a mnemonic of tools/rdna2_isa_tables.py or a built-in exception name; everything else counts as other. A D3D12 method name from a trace is printed only when it is a string literal of the runtime's sources (or Interface::Method with such an interface), and the end of a boot digest only in the three forms boot.ps1 writes. Paths appear only with --show-paths. Standard library only. It reads files; probing runs only llvm-mc --version, spirv-val --version and git rev-parse (--no-probe runs nothing). Exit 0 (a report), 1 with --strict on FAIL, 2 for bad arguments. Documented in docs/dev-tools.md.

Not done here (possible follow-up, separate PR): making make_game.py print "N of M translated" for the library and FSPX and warn on llvm-mc older than 23, and adding the slot failures, failed CreatePipelineState calls and tagged/plain count to scripts/windows-boot/boot.ps1's digest. The tool reports; it does not fix, retranslate or change any threshold of the build.

Sample report (real work folder after a full build with llvm-mc 21.1.8, and one 783 s boot; work folder path removed):

chain check
[WARN] tools
  llvm-mc     recorded 21.1.8 in 5 (5 records, amdgcn yes, via wsl); LLVM_MC now 21.1.8
  spirv-val   v2026.4
  translator  local dafa68abb710 in 5; checkout 7fb850e4e08b at a73a57e13; stale: bvh, exe, fspx, game, library
[OK] game  game programs (shaders.rpf)
  expected 26503  listings 26503  translated 26503 (100.0%)  failed 0
[FAIL] library  pipeline library compute
  expected 2684  listings 2684 (944 with rejected words)  translated 1844 (68.7%)  failed 840
  reasons     839 fall-through into undecodable words; 1 s_sethalt
  cause: llvm-mc 21.x leaves undecodable words (839 refusals; #1923)
[FAIL] fspx  FidelityFX FSPX
  expected 29  listings 29 (11 with rejected words)  translated 22 (75.9%)  failed 7
[OK] bvh  BVH builder  (52/52)    [OK] exe  executable  (12/12)
[WARN] contract
  modules     plain 28433; translator default tagged
  folders     present fspx, bvh, exe, library; absent fspx_compute, fspx_gfx
[FAIL] runtime
  loaded      total 28433, fspx 1866, fspx_compute 0, fspx_gfx 0, bvh 52, exe 12; descriptor table plain
  slot fails  slot 67 0x80070057 843; no translated compute shader 843
  d3d12       ID3D12Device2::CreatePipelineState failed 4, ID3D12Device2::CreatePipelineState unsupported 1
  pipelines   compute builds 830 (slow 40); compile gate waits 0
  device      fault lines 0, device lost lines 0, stalled dispatch lines 0; exit code none logged; boot.ps1: ran its full time limit (783 s), stopped
weakest link: library [FAIL]: llvm-mc 21.x leaves undecodable words (839 refusals; #1923)

(abridged: the cause lines of the tools, game, fspx, bvh, exe, contract and runtime blocks and the fspx reasons line are left out, and the bvh/exe count lines are shortened)

Tested

  • python -I tests/test_chain_check.py: 23 tests OK (synthetic work folders built by the test: broken and clean chains, mixed llvm-mc versions, refusal reasons and trace method names closed to what the sources contain, an index entry without its .spv is not counted, the 1% threshold on both sides, no names/paths without --show-paths, empty and partial folders give n/a or a verdict, --strict, --help thresholds, digest equal to make_game.translation_sources_digest(), UTF-16 log with and without BOM). One test reads the runtime sources and boot.ps1 and checks the 21 format-string fragments the log patterns depend on, so a reworded log line fails the test instead of silently reporting zero.
  • tests/test_runner_calls_all_tests.py 3 OK, tests/test_ci_registration.py 16 OK, all 13 tests/test_docs_*.py OK.
  • python -I scripts/check_no_game_data.py tools/chain_check.py tests/test_chain_check.py docs/dev-tools.md: exit 0; git diff --check origin/main..HEAD clean.
  • Real run: a full work folder (26,503 + 2,684 + 29 + 52 + 12 programs) and a 1.25-million-line boot log, about 28 s.

GPUs tested: n/a for the tool; the sample report comes from an NVIDIA RTX 4060, driver 610.88

AI-assisted: yes (Claude Code, Claude Opus 5.5, wrote the tool and its test; a second agent reviewed it)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2231 **Author:** [@MoonEyes](https://github.com/MoonEyes) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `tools/chain-check` --- ### 📝 Commits (4) - [`d41d6a1`](https://github.com/ubiquitarianism/leonida/commit/d41d6a16bb2c0831ccfd7ab1f097fce03d97b033) tools: chain_check.py, one page of counts for the whole shader chain (TOOL-CHAIN-CHECK) - [`044e271`](https://github.com/ubiquitarianism/leonida/commit/044e27122fca4d7225388c7627f8a5ea6e200c5e) chain_check: close the free-text filters and pin the runtime lines it reads - [`a6ec8f3`](https://github.com/ubiquitarianism/leonida/commit/a6ec8f38a1ed755220479439b6ee104226add9e2) chain_check: pin an unknown interface, a non-builtin exception and the slot-57 line - [`1b1fb2d`](https://github.com/ubiquitarianism/leonida/commit/1b1fb2db426f2ee76fa9a69ec7ee11b4794ed702) Merge remote-tracking branch 'origin/main' into tools/chain-check ### 📊 Changes **3 files changed** (+1213 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/dev-tools.md` (+33 -0) ➕ `tests/test_chain_check.py` (+405 -0) ➕ `tools/chain_check.py` (+775 -0) </details> ### 📄 Description Claimed in the coordination issue as: [TOOL-CHAIN-CHECK](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7185891745) ### What and why The shader chain (game files → llvm-mc → translator → SPIR-V → runtime pipelines) fails quietly link by link. On one Windows machine, llvm-mc 21.1.8 left 840 of the 2,684 compute programs of the pipeline library untranslated (839 "fall-through into undecodable words", 1 `s_sethalt`; #1923 measures the same gap). At boot the runtime then logged 843 `slot 67 ... failed with 0x80070057` lines. Today nothing connects those two counts: the build prints no "N of M" for the library, and `boot.ps1`'s digest shows neither slot failures nor failed `CreatePipelineState` calls. `tools/chain_check.py` prints one page with one block per link, each with OK / WARN / FAIL and its most likely cause, then the weakest link: - tools: the llvm-mc each family was disassembled with (`disasm.done`, `<family>_build.json`) and its AMDGPU target, spirv-val, and the recorded translator digest against the same digest recomputed from `make_game.py`'s `TRANSLATION_SOURCES` (a test pins it equal to `translation_sources_digest()`); - per family (game, library, FSPX, BVH, exe): unpacked, listings, listings with rejected words (`invalid_words`), translated (index entries with their `.spv`), up to 5 refusal reasons from `logs/shaders.log`; - contract: tagged vs plain modules (#2098) and which of the runtime's folders exist (`fspx_compute`...); - runtime, from `--log`: modules loaded, failed slot calls by slot and HRESULT, failed D3D12 calls, compute builds, compile-gate waits, device faults, exit code. Counts and fixed words only. A refusal reason is printed only when it matches a message `rdna2spirv.py` raises (read from its source), with a variable part kept only when it is a mnemonic of `tools/rdna2_isa_tables.py` or a built-in exception name; everything else counts as `other`. A D3D12 method name from a trace is printed only when it is a string literal of the runtime's sources (or `Interface::Method` with such an interface), and the end of a boot digest only in the three forms `boot.ps1` writes. Paths appear only with `--show-paths`. Standard library only. It reads files; probing runs only `llvm-mc --version`, `spirv-val --version` and `git rev-parse` (`--no-probe` runs nothing). Exit 0 (a report), 1 with `--strict` on FAIL, 2 for bad arguments. Documented in `docs/dev-tools.md`. Not done here (possible follow-up, separate PR): making `make_game.py` print "N of M translated" for the library and FSPX and warn on llvm-mc older than 23, and adding the slot failures, failed `CreatePipelineState` calls and tagged/plain count to `scripts/windows-boot/boot.ps1`'s digest. The tool reports; it does not fix, retranslate or change any threshold of the build. Sample report (real work folder after a full build with llvm-mc 21.1.8, and one 783 s boot; work folder path removed): ``` chain check [WARN] tools llvm-mc recorded 21.1.8 in 5 (5 records, amdgcn yes, via wsl); LLVM_MC now 21.1.8 spirv-val v2026.4 translator local dafa68abb710 in 5; checkout 7fb850e4e08b at a73a57e13; stale: bvh, exe, fspx, game, library [OK] game game programs (shaders.rpf) expected 26503 listings 26503 translated 26503 (100.0%) failed 0 [FAIL] library pipeline library compute expected 2684 listings 2684 (944 with rejected words) translated 1844 (68.7%) failed 840 reasons 839 fall-through into undecodable words; 1 s_sethalt cause: llvm-mc 21.x leaves undecodable words (839 refusals; #1923) [FAIL] fspx FidelityFX FSPX expected 29 listings 29 (11 with rejected words) translated 22 (75.9%) failed 7 [OK] bvh BVH builder (52/52) [OK] exe executable (12/12) [WARN] contract modules plain 28433; translator default tagged folders present fspx, bvh, exe, library; absent fspx_compute, fspx_gfx [FAIL] runtime loaded total 28433, fspx 1866, fspx_compute 0, fspx_gfx 0, bvh 52, exe 12; descriptor table plain slot fails slot 67 0x80070057 843; no translated compute shader 843 d3d12 ID3D12Device2::CreatePipelineState failed 4, ID3D12Device2::CreatePipelineState unsupported 1 pipelines compute builds 830 (slow 40); compile gate waits 0 device fault lines 0, device lost lines 0, stalled dispatch lines 0; exit code none logged; boot.ps1: ran its full time limit (783 s), stopped weakest link: library [FAIL]: llvm-mc 21.x leaves undecodable words (839 refusals; #1923) ``` (abridged: the cause lines of the tools, game, fspx, bvh, exe, contract and runtime blocks and the fspx reasons line are left out, and the bvh/exe count lines are shortened) ### Tested - `python -I tests/test_chain_check.py`: 23 tests OK (synthetic work folders built by the test: broken and clean chains, mixed llvm-mc versions, refusal reasons and trace method names closed to what the sources contain, an index entry without its `.spv` is not counted, the 1% threshold on both sides, no names/paths without `--show-paths`, empty and partial folders give n/a or a verdict, `--strict`, `--help` thresholds, digest equal to `make_game.translation_sources_digest()`, UTF-16 log with and without BOM). One test reads the runtime sources and `boot.ps1` and checks the 21 format-string fragments the log patterns depend on, so a reworded log line fails the test instead of silently reporting zero. - `tests/test_runner_calls_all_tests.py` 3 OK, `tests/test_ci_registration.py` 16 OK, all 13 `tests/test_docs_*.py` OK. - `python -I scripts/check_no_game_data.py tools/chain_check.py tests/test_chain_check.py docs/dev-tools.md`: exit 0; `git diff --check origin/main..HEAD` clean. - Real run: a full work folder (26,503 + 2,684 + 29 + 52 + 12 programs) and a 1.25-million-line boot log, about 28 s. GPUs tested: n/a for the tool; the sample report comes from an NVIDIA RTX 4060, driver 610.88 AI-assisted: yes (Claude Code, Claude Opus 5.5, wrote the tool and its test; a second agent reviewed it) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#2234
No description provided.