disasm_rdna2: decode 64-bit FLAT, GLOBAL and SCRATCH memory instructions #574

Merged
Neoplayer merged 2 commits from upstream-pr/580 into main 2026-11-22 15:35:40 +00:00
Neoplayer commented 2026-11-22 13:59:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Neoplayer on 2026-11-22T13:59:38Z.


Change

Add decoding for 64-bit RDNA 2 (gfx1013) FLAT, GLOBAL, and SCRATCH memory instructions ((w0 & 0xfc000000) == 0xdc000000, 130 forms total) in tools/disasm_rdna2.py, and synchronize tools/scan_unsupported_shaders.py:

  1. tools/disasm_rdna2.py:
    • Add FLAT_BASE_OPS plus segment tables FLAT_OPS (54 ops), GLOBAL_OPS (54 ops), and SCRATCH_OPS (22 load/store ops) covering loads, stores, d16 byte/short ops, and 32-bit/_x2 atomics.
    • Add _format_vgpr_range() and _decode_flat_family() handling segment dispatch (seg in 0..2, plus 8-byte aligned fallbacks for reserved seg=3 and unsupported segment/opcode combinations such as scratch atomics), GFX10 saddr == 0x7d (off) vs 64-bit saddr (s[n:n+1], vcc, ttmp[0:1]) on global_* and 32-bit saddr (s[n], m0, vcc_lo) on scratch_*, 12-bit unsigned flat offsets vs 12-bit signed global/scratch offsets, atomic vdst emission only when glc == 1, lds omitting vdst on global/scratch loads, glc/slc/dlc, and flat_truncated on short buffers.
  2. tools/scan_unsupported_shaders.py:
    • Register all 130 flat_*, global_*, and scratch_* mnemonics in KNOWN_RDNA2_BASE_OPCODES and include scratch_ in VMEM (Vector Memory / Buffer) in classify_isa_category().
  3. tests/rdna2_tools_check.py:
    • Add 24 LLVM-15-assembled gfx1013 golden vectors (test_golden_vectors), synthetic sweeps over all 130 forms (test_flat_global_scratch_opcode_tables_synthetic_forms), addressing/modifier distinction checks (test_flat_global_scratch_distinguishes_modifiers_and_addressing), truncation and reserved-segment alignment checks, and exact-assembly LLVM 15 comparison (test_llvm_comparison).

Verification

Commit under test: 7b13d9e on macOS arm64 (verified against official upstream llvm/llvm-project llvmorg-15.0.7 FLATInstructions.td definitions and local Homebrew LLVM 15.0.7 -mcpu=gfx1013):

  • LLVM_LIB=libLLVM-15.dylib LLVM_MC=llvm-mc LLVM_OBJCOPY=llvm-objcopy python3 -B tests/rdna2_tools_check.py: Ran 44 tests in 0.393s - OK (0 skips).
  • Cross-check script against pixel_aot.disassemble(..., libLLVM-15.dylib) across all 54 FLAT ops (both glc=0 & glc=1 for atomics), all 54 GLOBAL ops (saddr=off & s[2:3], glc=0 & glc=1), all 22 SCRATCH ops (saddr=off & s2), high/negative offsets, lds, vcc/ttmp[0:1]/m0: Checked 312 FLAT/GLOBAL/SCRATCH encodings against LLVM 15: mismatches=0.
  • All 20 platform-independent Python checks in .github/workflows/windows.yml passed (tests/rdna2_tools_check.py, tests/form_coverage_check.py, tests/shader_probe_check.py, tests/pso_readiness_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py, etc.).
  • python3 -B tests/pixel_aot_check.py binary and python3 -B tests/ffx_dispatch_aot_check.py (LLVM 15): exit 0.
  • git diff --check: exit 0.

MSVC, D3D12, and WARP builds (cmake --preset dev) were not run on this macOS host and remain covered by Windows CI.

Evidence and follow-up

All fixtures are source-built synthetic sequences assembled and checked against LLVM 15.0.7 -mcpu=gfx1013. Remaining unimplemented 64-bit encodings in tools/disasm_rdna2.py include DS (0xd8000000) and SDWA/DPP.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No docs or build requirements changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543252604 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/580). Originally posted by [Neoplayer](https://github.com/Neoplayer) on 2026-11-22T13:59:38Z. --- ## Change Add decoding for 64-bit RDNA 2 (`gfx1013`) FLAT, GLOBAL, and SCRATCH memory instructions (`(w0 & 0xfc000000) == 0xdc000000`, 130 forms total) in `tools/disasm_rdna2.py`, and synchronize `tools/scan_unsupported_shaders.py`: 1. `tools/disasm_rdna2.py`: - Add `FLAT_BASE_OPS` plus segment tables `FLAT_OPS` (54 ops), `GLOBAL_OPS` (54 ops), and `SCRATCH_OPS` (22 load/store ops) covering loads, stores, d16 byte/short ops, and 32-bit/`_x2` atomics. - Add `_format_vgpr_range()` and `_decode_flat_family()` handling segment dispatch (`seg` in `0..2`, plus 8-byte aligned fallbacks for reserved `seg=3` and unsupported segment/opcode combinations such as scratch atomics), GFX10 `saddr == 0x7d` (`off`) vs 64-bit `saddr` (`s[n:n+1]`, `vcc`, `ttmp[0:1]`) on `global_*` and 32-bit `saddr` (`s[n]`, `m0`, `vcc_lo`) on `scratch_*`, 12-bit unsigned `flat` offsets vs 12-bit signed `global`/`scratch` offsets, atomic `vdst` emission only when `glc == 1`, `lds` omitting `vdst` on `global`/`scratch` loads, `glc`/`slc`/`dlc`, and `flat_truncated` on short buffers. 2. `tools/scan_unsupported_shaders.py`: - Register all 130 `flat_*`, `global_*`, and `scratch_*` mnemonics in `KNOWN_RDNA2_BASE_OPCODES` and include `scratch_` in `VMEM (Vector Memory / Buffer)` in `classify_isa_category()`. 3. `tests/rdna2_tools_check.py`: - Add 24 LLVM-15-assembled `gfx1013` golden vectors (`test_golden_vectors`), synthetic sweeps over all 130 forms (`test_flat_global_scratch_opcode_tables_synthetic_forms`), addressing/modifier distinction checks (`test_flat_global_scratch_distinguishes_modifiers_and_addressing`), truncation and reserved-segment alignment checks, and exact-assembly LLVM 15 comparison (`test_llvm_comparison`). ## Verification Commit under test: `7b13d9e` on macOS arm64 (verified against official upstream `llvm/llvm-project` `llvmorg-15.0.7` `FLATInstructions.td` definitions and local Homebrew LLVM 15.0.7 `-mcpu=gfx1013`): - `LLVM_LIB=libLLVM-15.dylib LLVM_MC=llvm-mc LLVM_OBJCOPY=llvm-objcopy python3 -B tests/rdna2_tools_check.py`: `Ran 44 tests in 0.393s - OK` (0 skips). - Cross-check script against `pixel_aot.disassemble(..., libLLVM-15.dylib)` across all 54 FLAT ops (both `glc=0` & `glc=1` for atomics), all 54 GLOBAL ops (`saddr=off` & `s[2:3]`, `glc=0` & `glc=1`), all 22 SCRATCH ops (`saddr=off` & `s2`), high/negative offsets, `lds`, `vcc`/`ttmp[0:1]`/`m0`: `Checked 312 FLAT/GLOBAL/SCRATCH encodings against LLVM 15: mismatches=0`. - All 20 platform-independent Python checks in `.github/workflows/windows.yml` passed (`tests/rdna2_tools_check.py`, `tests/form_coverage_check.py`, `tests/shader_probe_check.py`, `tests/pso_readiness_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, etc.). - `python3 -B tests/pixel_aot_check.py binary` and `python3 -B tests/ffx_dispatch_aot_check.py` (LLVM 15): exit 0. - `git diff --check`: exit 0. MSVC, D3D12, and WARP builds (`cmake --preset dev`) were not run on this macOS host and remain covered by Windows CI. ## Evidence and follow-up All fixtures are source-built synthetic sequences assembled and checked against LLVM 15.0.7 `-mcpu=gfx1013`. Remaining unimplemented 64-bit encodings in `tools/disasm_rdna2.py` include `DS` (`0xd8000000`) and `SDWA`/`DPP`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No docs or build requirements changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:43:47 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!574
No description provided.