Repository navigation
Preserve the verified fallback shader disassembly - #8334
CristoDeveloper wants to merge 4 commits into
Conversation
Refactor shader disassembly logic to retain candidate results and offsets.
tupacfan04
left a comment
There was a problem hiding this comment.
The fallback selection is correct — it retains the widest candidate with zero invalid-instruction diagnostics, publishes the already-checked result when a second invocation fails, refuses an unconfirmed wider candidate, and still reports a total decoder failure. One real defect remains:
A previous output survives the new failure, and --skip-existing reuses it. When the unconfirmed fallback is rejected, tools/shader_disasm.py:167-190 makes one() return "failed" without touching out/<stem>.s. main() records FAILED and calls fail() before the stale-listing pruning (:256-258), so a previous out/one.s from an earlier run remains — including the bad listing the old code published for the same candidate. A rerun with --skip-existing treats any nonempty out/one.s as reusable (:241-249), skips the shader, and the build succeeds with the stale/bad listing. The new test uses a fresh out and asserts os.listdir(out) == [] (tests/test_shader_disasm.py:170-183), so it never seeds a previous one.s.
Fix: on a per-shader failure, remove the planned output for that shader (or write a failure marker and make --skip-existing refuse it), while keeping old listings for global toolchain failures as the pruning comment intends. Add a test that pre-creates out/one.s (the old bad/invalid listing) and runs both without and with --skip-existing; the unconfirmed-fallback run must not leave a successful-looking/reusable listing. The fallback-selection tests are otherwise meaningful. Synthetic only; no game files. AI-assisted (OpenCode).
|
Tested
AI-assisted (Claude Code). |
Refactor error handling and output path management in shader disassembly process.
|
Tested
Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047. |
Claimed in the coordination issue as: #8186 — shader_disasm fallback scan
Depends on: #7980 (overlapping fallback loop; this patch builds on main)
What and why
When the FSSM header does not identify the code range, publish the listing produced by the fallback scan. This removes a redundant decoder invocation and prevents a successful scan from publishing a listing with invalid instructions.
Root cause
The scan saved only the start offset of the longest candidate with zero invalid-instruction diagnostics. An invocation that failed without those diagnostics was also assigned that offset. The next invocation supplied the output for publication, even when its diagnostics differed from the scan's.
Impact
In synthetic tests, the old code failed after already decoding a clean candidate and separately exited 0 after publishing a candidate with one invalid instruction. With this change the first case writes the verified listing, and the second exits 1 without publishing a file.
Implementation
Retain the decoder result and its offset together. If the widest candidate without invalid-instruction diagnostics returned empty output, pass that result to the existing error path. A narrower successful decode is insufficient to establish where the program starts. If a per-shader decode produces no listing, remove that shader’s previous output so
--skip-existingretries it. The global toolchain probe runs before any shader is processed.Tested
Windows 11 (build 26200), Python 3.12.10, CPU only. Relevant upstream files were verified by blob hash and tested with synthetic inputs.
python -I tests/test_shader_disasm.py— 32 passed, one skipped. Two regressions fail with the original production file and pass with the patch. Separate cases check total decoder failure and a retry after a failed decode with an older listing present. Before the review fix, the older listing survived and the retry exited 0 withreused: 1.python -I tests/test_mc_command.py SplitCommandTest MissingLlvmMcTest.test_run_names_the_command_and_how_to_set_it MissingLlvmMcTest.test_run_names_the_tools_own_option MissingLlvmMcTest.test_run_passes_a_command_that_starts_through— 19 passed.python -I tests/test_report_paths.py SamePathTests MacVolumeTests FoldingVolumeTests— 17 passed, two platform-dependent skips.python -m compileall -q tools tests scriptson the fetched files,git diff --check, andpython -I scripts/check_no_game_data.py tools/shader_disasm.py tests/test_shader_disasm.py— passed.Compatibility
The header-based path runs one decoder invocation. Both backends use the existing listing writer and error reporting.
Coordination
The claim is linked above. #7980 addresses timeouts and repeated failures across files. It edits the same loop and may need a rebase.
Limitations
Verification used a partial checkout. Repository-wide suites that require the full tree were unavailable. AMDGPU-enabled llvm-mc was unavailable locally, so the regression used a subprocess stand-in. CMake, GPU, and full-corpus validation were outside these tests. If the filesystem prevents removing the stale listing, the command reports the path and asks for removal before resuming.
AI assistance
AI-assisted: yes (OpenAI Codex).
Checklist
docs/design.md(this patch changes the disassembler's result selection).