From d41d6a16bb2c0831ccfd7ab1f097fce03d97b033 Mon Sep 17 00:00:00 2001 From: MoonEyes <14891700+MoonEyes@users.noreply.github.com> Date: Thu, 26 Nov 2026 08:59:43 +0100 Subject: tools: chain_check.py, one page of counts for the whole shader chain (TOOL-CHAIN-CHECK) The links between the game files and the GPU fail quietly: an llvm-mc whose gfx1013 decoder rejects words leaves pipeline library programs untranslated, a translation from older translator sources keeps loading after the module contract changed, and the runtime's slot-67 refusals sit in a large log. tools/chain_check.py reads a make_game.py work folder (and optionally one run's log) and prints one block per link with OK/WARN/FAIL and the most likely cause: llvm-mc and spirv-val versions and the translator digest against this checkout; unpacked, listed and translated programs per family with up to 5 refusal reasons; tagged/plain modules and runtime folders; loaded modules, failed slot and D3D12 calls, builds, gate waits, faults and the exit code. The last line names the weakest link. Counts and fixed words only: refusal reasons are matched against the messages rdna2spirv.py raises, anything else counts as "other", and paths appear only with --show-paths. Exit 0 by default, 1 with --strict on FAIL. Standard library only; documented in docs/dev-tools.md. Co-Authored-By: Claude Opus 5.5 --- docs/dev-tools.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'docs/dev-tools.md') diff --git a/docs/dev-tools.md b/docs/dev-tools.md index d36091ec3..bd326662b 100644 --- a/docs/dev-tools.md +++ b/docs/dev-tools.md @@ -59,6 +59,37 @@ recorded events, and the exit status reports the analysis result. You can also run `python -I tools/boot_trace.py` with the same arguments. +## Check the shader chain of a work folder + +`tools/chain_check.py` prints one page of counts for each link between the game files and the GPU. It reads the +work folder that `make_game.py` built and, if you pass one, the log of one run: + +```powershell +python -I tools/chain_check.py +python -I tools/chain_check.py --log \.log --json +``` + +The page has one block per link, and each block gets a verdict (OK, WARN or FAIL) and its most likely cause: + +- tools: the llvm-mc each family was disassembled with and its AMDGPU target, spirv-val, and whether the + translator sources recorded in the folder still match this checkout's; +- one block per family (game programs, pipeline library, FSPX, BVH, executable): programs unpacked, listings, + listings with rejected words, programs translated, and up to 5 refusal reasons from `logs/shaders.log`; +- contract: tagged and plain modules, and the runtime folders that are present or absent (`fspx_compute` and the + others); +- runtime, from `--log` (`scripts/windows-boot/boot.ps1`'s `.log`): modules loaded, failed device slot calls, + failed D3D12 calls, compute pipeline builds, waits at the compile gate, device faults and the exit code. + +The last line names the weakest link: the first block, in chain order, with the worst verdict. + +A family is FAIL when more than 1% of its programs have no module. An llvm-mc older than 23 is a WARN (#1923). The +`--help` text lists every threshold. The report prints counts and fixed words only: no program names, no log lines +and no paths. A refusal reason is printed only when it matches a message from `tools/rdna2spirv.py`; any other +reason is counted as `other`. Add `--show-paths` to name the folder and the log, but not in a report you publish. + +The exit code is `0` whatever the verdicts. With `--strict` it is `1` when a block is FAIL, and bad arguments exit +`2`. Probing asks llvm-mc, spirv-val and git for their versions; `--no-probe` runs nothing. + ## Run a synthetic guest scene Use the existing headless runner with a loader and guest built on Windows -- cgit v1.2.3 From a6ec8f38a1ed755220479439b6ee104226add9e2 Mon Sep 17 00:00:00 2001 From: MoonEyes <14891700+MoonEyes@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:40:26 +0100 Subject: chain_check: pin an unknown interface, a non-builtin exception and the slot-57 line The trace test now feeds PS_Secret::Slot12 and expects one more "(other)"; the reasons test feeds "translator error SecretError" and expects "translator error #"; the runtime pins add the slot-57 failure fprintf of d3d12_xs_device.cpp. dev-tools.md says which trace names and digest endings are printed. Co-Authored-By: Claude Opus 5.5 --- docs/dev-tools.md | 4 +++- tests/test_chain_check.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'docs/dev-tools.md') diff --git a/docs/dev-tools.md b/docs/dev-tools.md index bd326662b..ed7fa4355 100644 --- a/docs/dev-tools.md +++ b/docs/dev-tools.md @@ -85,7 +85,9 @@ The last line names the weakest link: the first block, in chain order, with the A family is FAIL when more than 1% of its programs have no module. An llvm-mc older than 23 is a WARN (#1923). The `--help` text lists every threshold. The report prints counts and fixed words only: no program names, no log lines and no paths. A refusal reason is printed only when it matches a message from `tools/rdna2spirv.py`; any other -reason is counted as `other`. Add `--show-paths` to name the folder and the log, but not in a report you publish. +reason is counted as `other`. A D3D12 method name is printed only when the runtime's sources contain it, and the +end of a boot digest only in the forms boot.ps1 writes. Add `--show-paths` to name the folder and the log, but not +in a report you publish. The exit code is `0` whatever the verdicts. With `--strict` it is `1` when a block is FAIL, and bad arguments exit `2`. Probing asks llvm-mc, spirv-val and git for their versions; `--no-probe` runs nothing. diff --git a/tests/test_chain_check.py b/tests/test_chain_check.py index dc6611e99..38a0dad9b 100644 --- a/tests/test_chain_check.py +++ b/tests/test_chain_check.py @@ -226,10 +226,11 @@ class ChainCheckTest(unittest.TestCase): log = runtime_log(os.path.join(self.root, "run.log"), extra=( "[d3d12-trace] #9 PS_Secret_deadbeef failed", f"[d3d12-trace] #10 {SECRET}::Create failed", - "[d3d12-trace] #11 XboxID3D12Fence::Slot12 failed")) + "[d3d12-trace] #11 XboxID3D12Fence::Slot12 failed", + "[d3d12-trace] #12 PS_Secret::Slot12 failed")) write(os.path.join(self.root, "run.digest.txt"), f"== boot run: {SECRET} ran its full time limit\n") rt = block(chain_check.check(work, log, probe=False), "runtime") - self.assertEqual(rt["d3d12_problems"], {"(other) failed": 2, "ID3D12Device2::CreatePipelineState failed": 1, + self.assertEqual(rt["d3d12_problems"], {"(other) failed": 3, "ID3D12Device2::CreatePipelineState failed": 1, "XboxID3D12Fence::Slot12 failed": 1}) self.assertEqual(rt["ending"], "other") for ending, code in (("ran its full time limit (783 s), stopped", 0), @@ -283,7 +284,8 @@ class ChainCheckTest(unittest.TestCase): # Every runtime line the report counts, pinned to the source that prints it: a reworded message would make # its count fall to 0 and the runtime block pass in silence. pins = { - "runtime/shims/d3d12_xs_device.cpp": ["[rt] d3d12_xs: slot 67 call %llu failed with 0x%08lx"], + "runtime/shims/d3d12_xs_device.cpp": ["[rt] d3d12_xs: slot 67 call %llu failed with 0x%08lx", + "[rt] d3d12_xs: slot 57 call %llu failed with 0x%08lx"], "runtime/shims/d3d12_vulkan_device.cpp": [ "[rt] d3d12: %zu translated shaders (%zu fspx, %zu fspx_compute, ", "%zu fspx_gfx, %zu bvh, %zu exe) from %s", @@ -342,10 +344,12 @@ class ChainCheckTest(unittest.TestCase): f"2 {SECRET} source\n" f"1 E:\\work\\{SECRET}.s\n" "1 translator error KeyError\n" + "1 translator error SecretError\n" "1 secret_program_name\n") lib = block(chain_check.check(work, probe=False), "library") self.assertEqual(dict((r, n) for n, r in lib["reasons"]), - {"s_sethalt": 2, "# source": 2, "other": 2, "translator error KeyError": 1}) + {"s_sethalt": 2, "# source": 2, "other": 2, "translator error KeyError": 1, + "translator error #": 1}) def test_empty_and_partial_folders_are_na(self): empty = os.path.join(self.root, "empty") -- cgit v1.2.3