Repository navigation
rdna2spirv/fspx_unpack/make_game: direct binary RDNA2 decode backend (#1901) - #2323
SweatierKey wants to merge 4 commits into
Conversation
fe39b8e to
ca692f6
Compare
|
Tested
The default stays llvm-mc as described, so this lands zero behavioural change for existing setups while the AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine. |
|
Tested ca692f6 on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
8060b70 to
d9e792c
Compare
d9e792c to
5e517fb
Compare
|
Tested Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows
The failure is For The GPU suite (default AI-assisted (Claude Code); I checked the results. |
5e517fb to
1487c0f
Compare
|
Thank you @zneel for the RX 9070 XT GPU check and for pinpointing that exact SDWA inline-constant mismatch on Fixed in the base decoder PR #2038 (
|
1487c0f to
f4ae9bd
Compare
|
Tested
The failure is still The decoder is right here: It prints inline constant 242 on this 16-bit integer op as the literal Two possible fixes in the test:
No game files. AI-assisted (Claude Code). |
|
Thanks @TreXito for the RTX 3060 Ti check and for isolating that Fixed in base PR #2038 (
|
…-mc -disassemble fails to round-trip SDWA float inline constants
ccab6c7 to
eac43b1
Compare
|
Rebased onto
|
|
Retail FSPX backend comparison at eac43b1 On Xbox package 1.0.2.1, all 29 compute programs translated and passed Vulkan 1.2 validation through the Python listing backend. The LLVM listing backend passed 26 of the same 29 at the same PR revision.
I ran Windows, Ryzen 5 3600, CPython 3.14.10, LLVM 23.1.5 ( |
Flyander
left a comment
There was a problem hiding this comment.
The direct backend needs to fail closed when it encounters an unsupported multiword encoding. The decoder currently advances only four bytes for an unknown VOP3P opcode, so trusting its PCs can silently misparse the rest of the shader.
| if any(i.get("normalized") for i in insns): | ||
| raise Unsupported("reachable instruction with normalized encoding") | ||
| else: | ||
| if info.get("direct"): |
There was a problem hiding this comment.
[P2] Reject or preserve the complete size of unknown VOP3P instructions before trusting direct PCs. decode_bytes advances by the length returned from _decode_one; the unknown-opcode VOP3P path returns (None, 4) after reading its 8-byte base encoding (and it may also have a literal). The next dword is then decoded as a new instruction, and this direct path trusts those shifted PCs and can translate bogus control flow for retail shaders containing a VOP3P opcode absent from the table. Preserve the full encoding length, including literal handling, or reject the direct stream instead of translating it.
…ncodings in direct binary decode
|
Thanks @Flyander for catching that! Pushed both parts of the fix in
|
Flyander
left a comment
There was a problem hiding this comment.
The follow-up addresses my report: unknown VOP3P/VOP3 encodings now preserve their instruction width, the direct path fails closed on reachable unknown encodings, and targeted cases cover literals and unreachable embedded data. Thanks for the quick correction.
|
RTX 3070 readback on one of the nine differing FSPX listing pairs I ran the LLVM and Python translations of one retail wave32 compute shader from Xbox package 1.0.2.1 on the same synthetic input. Both versions preserved the entire 64 KiB buffer, including a nonzero sentinel, on two independent dispatches each (4/4 exact readbacks). Leonida’s full-workgroup interpreter predicted 128 aligned reads across two distinct words and zero stores per version. This establishes agreement on an inactive input. Active output and in-game image quality remain unverified. Across all nine pairs, a traversal from the compute entry point found external buffer or image writes in 3/9 LLVM modules and 9/9 Python modules. In six pairs only Python had a reachable output write. Whether the shader executes that write depends on the input. The GPU ran the original modules from Windows, Ryzen 5 3600, GeForce RTX 3070, NVIDIA 617.14, subgroup 32, CPython 3.14.10, LLVM 23.1.5 ( |
|
Tested
Not run: AI-assisted (Claude Code). |
|
Tested 18ffaf0 (merge base 7b7d73f) on NVIDIA GeForce RTX 5080, Linux 580.65.06: pass Tested the PR head merged with current main
Line-by-line against my main run (results that differ from main):
Not run: the full AI-assisted (Claude Code). |
Depends on #2038 (stacked on
rdna2-direct-decoder). Completes the pure-Python RDNA2 decode integration for #1901 (claim: #1902 (comment)).What this adds
tools/rdna2spirv.py: addsdecode_binary_file()sotranslate()and the CLI accept native.fssmandfspx/*.codebinaries directly (decoding straight intoshader_irviatools/rdna2_decode.pywithout spawningllvm-mcor writing/parsing.stext files). Direct decode preserves exact byte PCs across embedded undecodable data words, skipping thesame_encodingre-anchoring scan and pruning unreachable data viafold_far_branches+reachable_code.tools/fspx_unpack.py: adds--backend {llvm-mc,python}(defaultllvm-mc) forwardingwave32toshader_disasm.disasm(), enabling zero-llvm-mcdisassembly of all FSPX shaders including thev_dot4_i32_i8 op_sel:[0,1,0] op_sel_hi:[1,0,1]wordsllvm-mcrejects.make_game.py: adds--disasm-backend {llvm-mc,python}(defaultllvm-mc). Under--disasm-backend python,preflight()does not requirellvm-mc,disasm.donerecords a SHA-256 fingerprint ofrdna2_decode.py+rdna2_isa_tables.py, andshaders()passes--backend pythontoshader_disasm.py.Verification
python3 -m unittest tests/test_rdna2_direct_translate.py -v: 4/4 OK (direct.fssmand.codetranslation matches the.stext path byte-for-byte, embedded data word pruning,fspx_unpack --disasm --backend pythondecodesv_dot4_i32_i8 op_selwith 0 invalid words,make_game.py preflightsucceeds withoutllvm-mc,spirv-val --target-env vulkan1.2clean).python3 -m unittest tests/test_rdna2_decode.py tests/test_fspx_unpack.py tests/test_shader_disasm.py tests/test_text_write_line_endings.py: 45/45 OK.AI-assisted.