tools: add auto fallback to python disassembler in shader_disasm and shader_library #1712
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1712"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by Tortoche on 2026-11-25T09:15:53Z.
Claim:
SHADER-DISASM-AUTO-FALLBACK(#1608#issuecomment-7158019367)Findings:
#1608(#1608#issuecomment-7156808927,#1608#issuecomment-7157792566)Related:
#998AI-assisted: yes
Summary
tools/shader_disasm.py:backend="llvm-mc"as the default indisasm()and--backendso FSSM callers and existing tests are unchanged.backend="auto"(and--backend auto): runsllvm-mcfirst; ifbad == 0and output is non-empty, returns it immediately without invokingrdna2_decode. Otherwise runs the pure-Python decoder (rdna2_decode.disasm_bytes) and returns(py_asm, py_bad, "")iffpy_asm.strip()and (not asm.strip()orpy_bad < bad); otherwise returns thellvm-mcresult.main()to runprobe(a.mcpu)whena.backend in ("llvm-mc", "auto").tools/shader_library.py:--backend(choices=("auto", "llvm-mc", "python"),default="auto").make_game.pyis intentionally untouched to stay conflict-free with#1592and#1708.disasm.probe(a.mcpu)upfront beforeThreadPoolExecutorwhenworkis non-empty anda.backend in ("llvm-mc", "auto").backend=a.backendtodisasm.disasm(...)inone(job).tests/test_shader_disasm.py: addedDisasmAutoBackendTest(test_auto_backend_falls_back_to_python_on_invalid_words,test_auto_backend_preserves_clean_llvm_mc_output,test_auto_backend_keeps_llvm_mc_when_python_not_better).tests/test_shader_library.py: addedtest_disasm_auto_falls_back_per_program_without_regressing_clean_programs.Verification
python3 -I scripts/check_no_game_data.py tools/shader_disasm.py tools/shader_library.py tests/test_shader_disasm.py tests/test_shader_library.py-> exit 0python3 -m compileall -q make_game.py tools tests-> exit 0python3 -I tests/test_shader_disasm.py-> Ran 34 tests in 8.384s, OKpython3 -I tests/test_shader_library.py-> Ran 23 tests in 0.215s, OKpython3 -I tests/test_library_shaders_stage.py-> Ran 17 tests in 7.336s, OKpython3 -I tests/test_text_write_line_endings.py-> Ran 3 tests in 15.974s, OKpython3 -I tests/test_ci_registration.py-> Ran 16 tests in 9.878s, OKImported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T10:29:18Z.
Review: COMMENTED
Independent native Windows verification at
70315b5f: all 34 disassembler and 23 shader-library tests passed. A separate CLI run with synthetic input found one gap in auto mode when llvm-mc is unavailable. Details inline.AI-assisted review. CPU only, synthetic inputs.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T10:29:18Z.
Code review location:
tools/shader_library.py; line 449This upfront probe can exit before
autoreaches the Python decoder. I pointedLLVM_MCat a nonexistent executable and used the repository's synthetic FSSM and shader-library fixtures. Both CLIs exited 1 with zero listings inautomode. Explicit--backend pythonwith the same inputs exited 0 and wrote one and four listings, respectively. This also affectsshader_library.py --disasmby default. Couldautoswitch to the Python backend when the probe fails, while explicitllvm-mckeeps the hard error? The same check applies toshader_disasm.py.Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T10:33:35Z.
Tested
70315b5fdon Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain57ba40bd6(Python tools; no GPU):tests/test_shader_disasm.py+tests/test_shader_library.py: 57 passed, 28 subtests passed at this head.main: 2 failed, 55 passed, 28 subtests —test_auto_backend_falls_back_to_python_on_invalid_wordsand the per-program fallback inshader_library.--backend autopass over a real listing set with llvm-mc rejecting words — this machine has the Homebrewllvm-mc, so the fallback itself is exercised through the tests' mocks; the defaultllvm-mcpath is unchanged by design.AI-assisted; synthetic fixtures only, no game data.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:00:04Z.
Hi @Tortoche, thanks for this pull request. It currently conflicts with
main(conflicting file(s):tools/shader_disasm.py,tools/shader_library.py), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:04:37Z.
#1712 | head
fef2f758be(merged cleanly with maind48a957bb) |python -I tests/test_shader_disasm.py&python -I tests/test_shader_library.py| red on main:FAILED (failures=1)(bad=2 != 0) andFAILED (failures=1, skipped=1)(probecalled 0 times) | green on PR+main:34 tests OKand26 tests OK (skipped=1)| Windows 11, Python 3.12.10 | AI-assisted: yesAudited
disasmandmainintools/shader_disasm.pyandtools/shader_library.py(adding--backend autoso cleanllvm-mcdisassemblies are preserved untouched while programs withinvalid_words > 0fall back per-program tordna2_decodeonly whenpy_bad < bad, and falling back to"python"whenprobe()fails). Also verifiedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK), andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:33:26Z.
Merged after local re-verification: this PR merged onto
maine06955b7fwithout conflict, and its test file(s) (tests/test_shader_disasm.py,tests/test_shader_library.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.