Skip to content

SHADER-873: Fix gfx1013 legacy MAD decoding - #5011

Closed
gut0to wants to merge 1 commit into
ItsNotRexed:mainfrom
gut0to:gut0to/shader-873-gfx1013-mad-legacy
Closed

gut0to wants to merge 1 commit into
ItsNotRexed:mainfrom
gut0to:gut0to/shader-873-gfx1013-mad-legacy

Conversation

@gut0to

@gut0to gut0to commented Nov 23, 2026

Copy link
Copy Markdown

Summary

The pure-Python gfx1013 decoder named VOP3 opcode 0x140 as v_fma_legacy_f32, which is the GFX10.3 meaning of that encoding. On the console target it is the unfused v_mad_legacy_f32, as already documented in docs/design.md and emitted by LLVM's gfx1013 disassembler.

Rename the table entry to the gfx1013 mnemonic so listings decoded by the Python backend reach the existing v_mad_legacy_f32 translator path. Add a hand-encoded regression that checks the mnemonic, all four vector operands, and the formatted instruction's parser round-trip.

Work item: SHADER-873, claimed in the coordination issue.

Validation

  • python -I tests/test_rdna2_decode.py: 10 tests passed, 1 optional LLVM parity test skipped.
  • git diff --check: clean.
  • Corpus recount not run because this machine has no game files; the coordinator's finder reported 1,022 of 1,473 Python-backend listings refusing on the wrong mnemonic.
  • No game files.

AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor

Independent check of 73c1a041 — pass (CPU only), and playability-relevant: gfx1013 is the Xbox GPU family.

Environment: Windows 11, CPython 3.15.2, no game files.

  • python -I tests/test_rdna2_decode.py → 10 tests, 1 skip on the PR head
  • Negative control: same suite against main's tools/rdna2_isa_tables.py → 1 failure — the legacy VOP3 MAD decodes wrong on the parent; the head fixes it
  • compileall clean on rdna2_isa_tables.py

AI-assisted (Devin).

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 73c1a04 the same eight synthetic bytes decode as legacy MAD on both gfx1013 and gfx1030. LLVM 21 selects MAD on gfx1013 and FMA on gfx1030. Both #2786 and #4928 match LLVM on both targets through the Python disassembly entry point. Please drop the shared-table change as superseded. Across the three heads the suites had 93 passes and three skips. AI-assisted CPU validation.

@DenRakEiw

Copy link
Copy Markdown
Contributor

Independent review of 73c1a04198cc73636eb21b6d0fdae6242366b2a2 — pass (CPU-only, no game data).

Environment: Windows 11 x64, Python 3.12.10, LLVM 21 llvm-mc (wsl -d Ubuntu-24.04 -e /usr/lib/llvm-21/bin/llvm-mc).

  • Merge & hygiene: Merges cleanly against origin/main (3faac557); git diff --check is clean.
  • LLVM cross-check: Direct llvm-mc --disassemble -triple=amdgcn-- on the test encoding (0x04 0x00 0x40 0xd5 0x01 0x05 0x0e 0x04) confirms v_mad_legacy_f32 v4, v1, v2, v3 on gfx1013 (vs. v_fma_legacy_f32 v4, v1, v2, v3 on gfx1030). No remaining v_fma_legacy_f32 references in tools/ or tests/, and tools/rdna2spirv.py already translates v_mad_legacy_f32.
  • Tests: python -I tests/test_rdna2_decode.py -v → 10 tests OK (1 skipped) without LLVM_MC. (Running with WSL LLVM 21 LLVM_MC passes the new test and hits an unrelated pre-existing SDWA f16 encoding mismatch on ps_sdwa_f16_const.asm.)
  • Negative control: Running the PR test suite against origin/main's tools/rdna2_isa_tables.py reproduces 1 failure on test_gfx1013_vop3_140_is_mad_legacy ('v_fma_legacy_f32' != 'v_mad_legacy_f32').

AI-assisted (Gemini 4 Neon).

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 73c1a04 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_rdna2_decode.py -> Ran 10 tests, OK (skipped=1)
  • Negative control (tools/rdna2_isa_tables.py swapped to upstream/main): FAILED (failures=1)

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@gut0to

gut0to commented Nov 23, 2026

Copy link
Copy Markdown
Author

Thanks for the cross-target validation. I checked #4928: its target-aware decoding handles the gfx1013/gfx1030 mnemonic difference, while this PR's shared-table rename cannot represent both correctly. I agree #5011 is superseded and should be closed so the target-aware implementation remains the single contribution for this fix. No code change to #5011 is needed.

@gut0to gut0to closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants