shader: decode v_fma_mix* neg/abs modifiers in disasm_rdna2 #756

Merged
Ammmae0x merged 1 commit from upstream-pr/762 into main 2026-11-23 01:40:42 +00:00
Ammmae0x commented 2026-11-23 01:25:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T01:25:16Z.


Fixes #745

Change

tools/disasm_rdna2.py previously formatted all VOP3P encodings with neg_lo:[...] (w1[31:29]) and neg_hi:[...] (w0[10:8]) suffix modifiers. On RDNA 2 mixed-precision FMA instructions (v_fma_mix_f32, v_fma_mixlo_f16, v_fma_mixhi_f16), those bits instead encode per-source abs (|src|) and neg (-src, or -|src| when combined), causing pixel_aot.parse_fma_mix to reject disassembled v_fma_mix* instructions.

  • Extracted a shared _format_operand_modifiers(val, is_abs, is_neg) helper in tools/disasm_rdna2.py for both VOP3P and VOP3 operand formatting.
  • Updated VOP3P decoding so v_fma_mix* opcodes apply w0[10:8] as inline abs and w1[31:29] as inline neg on the 3 source operands and omit neg_lo: / neg_hi: suffixes, while leaving neg_lo / neg_hi unchanged for v_pk_* and v_dot*.
  • Added test_vop3p_fma_mix_inline_abs_neg_modifiers in tests/rdna2_tools_check.py covering the issue encoding (0c1920cc2c26524c), all three v_fma_mix* opcodes with abs, neg, -|...|, op_sel, op_sel_hi, clamp, 32-bit literal operands, pixel_aot.parse_fma_mix + fma_mix_operand round-trips, v_dot2_f32_f16 retaining neg_lo/neg_hi, and negative controls (parse_fma_mix rejecting neg_lo/neg_hi and f32 high-half selection; truncated v_fma_mix* literal decoding as vop3p_truncated).

Verification

Tested on commit a455ccf (base aeb45da), Windows x64 (MSVC 19.50.35727, CMake 4.2.3-msvc3, Ninja 1.12.1, Python 3.12.8):

  • ctest --preset dev -N: 328 tests registered (matches baseline).
  • cmake --build --preset dev --target offscreen_check root_probe root_device_probe & release: 0 errors, 0 warnings.
  • .\out\pe-env\Scripts\python.exe -B tests/rdna2_tools_check.py: Ran 58 tests in 1.824s, OK (skipped=1) (existing llvm-mc skip when unavailable on Windows).
  • ctest --preset dev --no-tests=error -R "rdna2_tools_check|shader_|pso_readiness|pixel_aot_" -V: 35/35 passed, 0 failed (264.24s).
  • ctest --preset release --no-tests=error -R "rdna2_tools_check|shader_|pso_readiness|pixel_aot_" -V: 35/35 passed, 0 failed (239.50s).
  • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: exit 0 (form coverage checks passed).
  • .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py: exit 0 (Checked 11 Markdown files and 137 links.).
  • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py: exit 0 (Checked 618 tracked source, script and build/CI files: no bidirectional controls.).

Evidence and follow-up

All new checks use synthetic RDNA 2 VOP3P machine-code words and the existing pure-Python pixel_aot.parse_fma_mix / fma_mix_operand helpers in tests/rdna2_tools_check.py.

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.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6550369859 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/762). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T01:25:16Z. --- Fixes #745 ## Change `tools/disasm_rdna2.py` previously formatted all VOP3P encodings with `neg_lo:[...]` (`w1[31:29]`) and `neg_hi:[...]` (`w0[10:8]`) suffix modifiers. On RDNA 2 mixed-precision FMA instructions (`v_fma_mix_f32`, `v_fma_mixlo_f16`, `v_fma_mixhi_f16`), those bits instead encode per-source `abs` (`|src|`) and `neg` (`-src`, or `-|src|` when combined), causing `pixel_aot.parse_fma_mix` to reject disassembled `v_fma_mix*` instructions. - Extracted a shared `_format_operand_modifiers(val, is_abs, is_neg)` helper in `tools/disasm_rdna2.py` for both VOP3P and VOP3 operand formatting. - Updated VOP3P decoding so `v_fma_mix*` opcodes apply `w0[10:8]` as inline `abs` and `w1[31:29]` as inline `neg` on the 3 source operands and omit `neg_lo:` / `neg_hi:` suffixes, while leaving `neg_lo` / `neg_hi` unchanged for `v_pk_*` and `v_dot*`. - Added `test_vop3p_fma_mix_inline_abs_neg_modifiers` in `tests/rdna2_tools_check.py` covering the issue encoding (`0c1920cc2c26524c`), all three `v_fma_mix*` opcodes with `abs`, `neg`, `-|...|`, `op_sel`, `op_sel_hi`, `clamp`, 32-bit literal operands, `pixel_aot.parse_fma_mix` + `fma_mix_operand` round-trips, `v_dot2_f32_f16` retaining `neg_lo`/`neg_hi`, and negative controls (`parse_fma_mix` rejecting `neg_lo`/`neg_hi` and f32 high-half selection; truncated `v_fma_mix*` literal decoding as `vop3p_truncated`). ## Verification Tested on commit `a455ccf` (base `aeb45da`), Windows x64 (`MSVC 19.50.35727`, `CMake 4.2.3-msvc3`, `Ninja 1.12.1`, `Python 3.12.8`): - `ctest --preset dev -N`: `328` tests registered (matches baseline). - `cmake --build --preset dev --target offscreen_check root_probe root_device_probe` & `release`: 0 errors, 0 warnings. - `.\out\pe-env\Scripts\python.exe -B tests/rdna2_tools_check.py`: `Ran 58 tests in 1.824s`, `OK (skipped=1)` (existing `llvm-mc` skip when unavailable on Windows). - `ctest --preset dev --no-tests=error -R "rdna2_tools_check|shader_|pso_readiness|pixel_aot_" -V`: `35/35 passed`, `0 failed` (`264.24s`). - `ctest --preset release --no-tests=error -R "rdna2_tools_check|shader_|pso_readiness|pixel_aot_" -V`: `35/35 passed`, `0 failed` (`239.50s`). - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: exit `0` (`form coverage checks passed`). - `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py`: exit `0` (`Checked 11 Markdown files and 137 links.`). - `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py`: exit `0` (`Checked 618 tracked source, script and build/CI files: no bidirectional controls.`). ## Evidence and follow-up All new checks use synthetic RDNA 2 VOP3P machine-code words and the existing pure-Python `pixel_aot.parse_fma_mix` / `fma_mix_operand` helpers in `tests/rdna2_tools_check.py`. ## 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. - [x] I updated README/docs when a capability or build requirement 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:44:40 +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!756
No description provided.