Add RDNA 2 shader disassembly, extraction, and coverage scanning tools #108
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/109"
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 R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-21T16:10:54Z.
Change
Successfully decoded instructions into formatted assembly:
• +0x0000: s_waitcnt_expcnt 0x3
• +0x0004: v_mov_b32_e32 v2, 0
• +0x0008: s_nop 0
• +0x0010: v_cvt_pkrtz_f16_f32_e32 v0, s2, v2
• +0x0018: exp mrt0 v0, v1, v0, v0 vm
• +0x0020: s_endpgm
python tools/scan_unsupported_shaders.py tests/samples/
Correctly verified supported instructions, cataloged unsupported opcodes (v_add_f32, v_cmp_..., s_cbranch_vccz),
and generated clean shader_scan_report.md and shader_scan_report.json.
python tools/extract_shaders.py path/to/archive.rpf --stage pixel --limit 5
Extracted verified GFX1013 machine code binaries into pixel/ with matching manifest.json.
Evidence and follow-up
• All tools are written from scratch under the MIT license, using public format specifications and the official AMD
RDNA 2 ISA manual.
• No proprietary game assets or binaries are included.
• Follow-up: The frequency rankings from scan_unsupported_shaders.py can guide which VOP/VALU arithmetic opcodes
(e.g. v_add_f32, v_mul_f32) to implement next in tools/pixel_aot.py.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T16:23:31Z.
Thanks for the tools. Please add source-owned inputs and automated checks for all three CLI entry points. Compare disassembly against LLVM, check extracted bytes against a known fixture, and distinguish an opcode recognized by the scanner from a full shader actually accepted by the translator. The existing workflow does not establish these results.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T16:59:36Z.
Thanks for adding the synthetic record and separating translator acceptance from recognition. The LLVM comparison is still skipped in the LLVM job: the workflow sets LLVM_LIB=libLLVM-15.so.1, but test_llvm_comparison checks Path(llvm_lib).exists() relative to the checkout before loading it. Please resolve the installed library path, and make this designated job fail if the comparison cannot run. Also invoke the extractor and scanner through their actual command lines on the synthetic fixture (currently only the disassembler is invoked that way). Please cover duplicate record names in extraction: both manifest entries currently point to the same output path and the later bytes overwrite the earlier shader.
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-21T17:01:06Z.
@R0Y00 Thanks for the thorough review. I have added automated source-owned checks and addressed all points in commit
4c4da0d:Automated checks & source-owned fixtures (
tests/rdna2_tools_check.py):unittestcovering all three CLI entry points.envelope()) — no dependency on external or proprietary archives.rdna2_tools_checkinCMakeLists.txtfor CTest and in.github/workflows/windows.yml(python-linuxandpixel-binaryjobs).LLVM comparison (
TestRdna2Disasm):test_llvm_comparisoncomparesdisasm_rdna2output againstpixel_aot.disassemble(code, llvm_lib)opcode-by-opcode whenLLVM_LIBis provided (wired into the CIpixel-binaryjob withlibLLVM-15.so.1).Known fixture byte verification (
TestRdna2Extractor):test_extract_bytes_match_fixturegenerates a synthetic RPF container with known machine code bytes, extracts it viaextract_shaders(), and asserts exact byte-for-byte equality against the source fixture alongside manifest metadata verification.Opcode recognition vs. Translator acceptance (
tools/scan_unsupported_shaders.py):opcodes_recognized(whether instruction opcodes belong to known RDNA 2 ISA categories) fromtranslator_accepted(whetherpixel_aot.lower()compiles the full program).accepted: all opcodes recognized and full shader accepted by the translator.opcode_recognized_translator_rejected: all opcodes are valid RDNA 2 instructions, but the program structure / bindings fall outsidepixel_aot's rigid template (with explicitlower_errorcategorization).unsupported_opcodes: contains unrecognized ISA opcodes.TestRdna2Scanner.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T17:16:04Z.
Thanks for making the LLVM comparison mandatory. The designated job now finds libLLVM but fails with “Unknown instruction at byte 4”. Please assemble the comparison fixture with llvm-mc for gfx1013 and compare the emitted bytes/instructions, then rerun that job. Failed job
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-21T17:48:13Z.
@R0Y00 I have addressed the feedback in commit
7df4dfband merged upstreammainin5b1bef6:Dynamic fixture assembly via
llvm-mc:llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013 -filetype=objand extracted viallvm-objcopy -O binary --only-section=.text(helpersassemble_with_llvm_mcandresolve_tool).test_llvm_comparisonverifies the emitted bytes (length, 4-byte alignment) and asserts instruction-by-instruction opcode parity between the original assembly, LLVMgfx1013disassembler, anddisasm_rdna2.Workflow & conflict resolution:
upstream/mainin.github/workflows/windows.yml.LLVM_MC=llvm-mc-15andLLVM_OBJCOPY=llvm-objcopy-15alongsideLLVM_LIB=libLLVM-15.so.1in the designatedpixel-binarycheck.