shader: fix RDNA2 EXP, VINTRP, SMEM, MIMG and literal decoding in disasm_rdna2 #511

Merged
PrivacyOnion merged 2 commits from upstream-pr/517 into main 2026-11-22 09:57:37 +00:00
PrivacyOnion commented 2026-11-22 08:47:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by PrivacyOnion on 2026-11-22T08:47:03Z.


## Summary

  • Fix RDNA 2 / GFX1013 instruction decoding bugs in tools/disasm_rdna2.py:
    • EXP (0xf8000000): decode en (w0[3:0]), target (w0[9:4], including mrtz and param0..31), compr (w0[10]), done (w0[11]), and vm (w0[12]) instead of shifted offsets; format disabled channels as off and compressed (compr) exports accurately.
    • VINTRP (0xc8000000): fix swapped attr (w0[15:10]) and chan (w0[9:8]) bitfields.
    • SMEM (0xf4000000): use per-opcode destination register widths (1/2/4/8/16) and base widths (2 for s_load_*, 4 for s_buffer_load_*), decode soffset (w1[31:25]) vs null + 21-bit offset, and emit glc/dlc modifiers.
    • MIMG (0xf0000000): add full 64-bit contiguous and 12/16/20-byte NSA (nsize) decoding for image_load*, image_store*, image_sample*, image_gather4*, image_get_resinfo, and image_get_lod, including dmask, dim:SQ_RSRC_IMG_*, sampler descriptors, and modifiers (unorm, glc, slc, r128, lwe, dlc, d16).
    • Literals & VOP1/VOP2: consume trailing 32-bit literal dwords (src == 255) in SOP1, SOP2, VOP1, and VOP2 plus mandatory literals in v_fmamk_f32 (0x2c) and v_fmaak_f32 (0x2d), preventing instruction stream desynchronization; add GFX10 VOP1 rounding opcodes (0x20..0x24: v_fract/trunc/ceil/rndne/floor_f32_e32).
  • Expand tests/rdna2_tools_check.py with golden vectors for all fixed/added encodings, multi-instruction literal alignment and truncation tests, and full LLVM 15 gfx1013 round-trip coverage in test_llvm_comparison.

Verification

  • Commands run:
    • out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py -v -> OK (32 tests, 1 skipped locally without LLVM_LIB)
    • out/pe-env/Scripts/python.exe -B tests/pso_readiness_check.py -> PASS
    • out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py -> PASS
    • out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py -> PASS
    • out/pe-env/Scripts/python.exe -B tests/docs_links_check.py -> PASS
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6540436895 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/517). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-22T08:47:03Z. --- ## Summary - Fix RDNA 2 / GFX1013 instruction decoding bugs in `tools/disasm_rdna2.py`: - **EXP (`0xf8000000`)**: decode `en` (`w0[3:0]`), `target` (`w0[9:4]`, including `mrtz` and `param0..31`), `compr` (`w0[10]`), `done` (`w0[11]`), and `vm` (`w0[12]`) instead of shifted offsets; format disabled channels as `off` and compressed (`compr`) exports accurately. - **VINTRP (`0xc8000000`)**: fix swapped `attr` (`w0[15:10]`) and `chan` (`w0[9:8]`) bitfields. - **SMEM (`0xf4000000`)**: use per-opcode destination register widths (`1/2/4/8/16`) and base widths (`2` for `s_load_*`, `4` for `s_buffer_load_*`), decode `soffset` (`w1[31:25]`) vs `null` + 21-bit offset, and emit `glc`/`dlc` modifiers. - **MIMG (`0xf0000000`)**: add full 64-bit contiguous and 12/16/20-byte NSA (`nsize`) decoding for `image_load*`, `image_store*`, `image_sample*`, `image_gather4*`, `image_get_resinfo`, and `image_get_lod`, including `dmask`, `dim:SQ_RSRC_IMG_*`, sampler descriptors, and modifiers (`unorm`, `glc`, `slc`, `r128`, `lwe`, `dlc`, `d16`). - **Literals & VOP1/VOP2**: consume trailing 32-bit literal dwords (`src == 255`) in `SOP1`, `SOP2`, `VOP1`, and `VOP2` plus mandatory literals in `v_fmamk_f32` (`0x2c`) and `v_fmaak_f32` (`0x2d`), preventing instruction stream desynchronization; add GFX10 VOP1 rounding opcodes (`0x20..0x24`: `v_fract/trunc/ceil/rndne/floor_f32_e32`). - Expand `tests/rdna2_tools_check.py` with golden vectors for all fixed/added encodings, multi-instruction literal alignment and truncation tests, and full LLVM 15 `gfx1013` round-trip coverage in `test_llvm_comparison`. ## Verification - Commands run: - `out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py -v` -> OK (32 tests, 1 skipped locally without `LLVM_LIB`) - `out/pe-env/Scripts/python.exe -B tests/pso_readiness_check.py` -> PASS - `out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py` -> PASS - `out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py` -> PASS - `out/pe-env/Scripts/python.exe -B tests/docs_links_check.py` -> PASS
upstream-sync closed this pull request 2026-11-24 06:43:28 +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!511
No description provided.