shader: name special source operands in disasm_rdna2 #842

Merged
marquezinii merged 1 commit from upstream-pr/848 into main 2026-11-23 12:54:26 +00:00
marquezinii commented 2026-11-23 12:43:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by marquezinii on 2026-11-23T12:43:53Z.


Change

decode_s_reg in tools/disasm_rdna2.py had no names for source operand codes 235-239, 248 and 251-254 and printed them as s235..s254. Those SGPRs do not exist (SGPRs end at s105). The codes select hardware values: src_shared_base, src_shared_limit, src_private_base, src_private_limit, src_pops_exiting_wave_id, src_vccz, src_execz, src_scc and src_lds_direct. 248 is the 1/(2*pi) inline constant. The decoder now uses the LLVM spellings. decode_s_reg64 prints 248 as 0.15915494309189532, which is how LLVM spells it for 64-bit operands. Every encoding that goes through these helpers changes: VOP1/VOP2/VOPC/VOP3 sources and SOP1/SOP2/SOPC operands.

The wrong names also reached the scanner. In binary mode, scan_unsupported_shaders.py classifies the disasm_rdna2 text, so a read of SCC was counted as a supported SGPR read:

fd02007e  main:    v_mov_b32_e32 v0, s253      is_instruction_supported -> True
          branch:  v_mov_b32_e32 v0, src_scc   is_instruction_supported -> False

Independent problem, no linked issue. No open PR touches tools/disasm_rdna2.py.

AI-assisted.

Verification

Branch on e97090a. Windows 11 build 26300, Python 3.15.2 (venv) and 3.13.18.

  • I found the mismatches by comparing disasm_rdna2.decode_instruction with llvm-mc --disassemble -mcpu=gfx1013 (LLVM 21.1.8) on random instruction words in each encoding family. The encodings and spellings in the new vectors come from llvm-mc -mcpu=gfx1013 -show-encoding. On the branch, the same comparison over 1500 words per family shows no special-operand mismatches. src_lds_direct in a scalar slot is the one exception: LLVM prints the same name but adds an "invalid register" comment.
  • python -B tests/rdna2_tools_check.py TestRdna2Disasm.test_golden_vectors: on main this fails at the first new vector (eb02007e: got v_mov_b32_e32 v0, s235, expected ... src_shared_base). On the branch it passes.
  • python -B tests/rdna2_tools_check.py: Ran 72 tests ... OK (skipped=1) on 3.15 and 3.13. The skip is test_llvm_comparison because LLVM_LIB is not set.
  • All 25 pure-Python checks from the workflow pass.
  • ctest --preset dev --no-tests=error -E '_hardware$' (dev preset, SPIR-V tools on PATH, -j 4): 309 passed, 2 skipped (bvh_wave64_warp and wave_shuffle_warp, exit 77), and 2 timed out under parallel load (pixel_aot_comparisons_warp and pixel_aot_predicate_rounding_warp). Rerun alone with -j 1, those two passed in 11.5 s and 9.2 s.

Not run: the Ubuntu LLVM 15 job. I added six lines to the test_llvm_comparison fixture (src_shared_base, src_pops_exiting_wave_id, src_scc and src_lds_direct as v_mov_b32_e32 sources, 0.15915494 in v_add_f32_e32 and 0.15915494309189532 in v_add_f64). That job compares them with LLVM 15's disassembly. I checked the same lines with LLVM 21 only.

Evidence and follow-up

The new vectors are instruction encodings produced by llvm-mc. No external data is involved.

The same comparison found two other disassembler mismatches that this PR does not fix:

  • VOP1 v_cvt_u32_f64_e32, v_cvt_i32_f64_e32 and v_cvt_f32_f64_e32 print the 32-bit destination as a pair (v[66:67] instead of v66). The e64 forms are correct.
  • v_interp_mov_f32 prints its parameter as a VGPR (v0/v1/v2) instead of p10/p20/p0.

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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6559591290 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/848). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-23T12:43:53Z. --- ## Change `decode_s_reg` in `tools/disasm_rdna2.py` had no names for source operand codes 235-239, 248 and 251-254 and printed them as `s235`..`s254`. Those SGPRs do not exist (SGPRs end at `s105`). The codes select hardware values: `src_shared_base`, `src_shared_limit`, `src_private_base`, `src_private_limit`, `src_pops_exiting_wave_id`, `src_vccz`, `src_execz`, `src_scc` and `src_lds_direct`. 248 is the 1/(2*pi) inline constant. The decoder now uses the LLVM spellings. `decode_s_reg64` prints 248 as `0.15915494309189532`, which is how LLVM spells it for 64-bit operands. Every encoding that goes through these helpers changes: VOP1/VOP2/VOPC/VOP3 sources and SOP1/SOP2/SOPC operands. The wrong names also reached the scanner. In binary mode, `scan_unsupported_shaders.py` classifies the `disasm_rdna2` text, so a read of SCC was counted as a supported SGPR read: ```text fd02007e main: v_mov_b32_e32 v0, s253 is_instruction_supported -> True branch: v_mov_b32_e32 v0, src_scc is_instruction_supported -> False ``` Independent problem, no linked issue. No open PR touches `tools/disasm_rdna2.py`. AI-assisted. ## Verification Branch on `e97090a`. Windows 11 build 26300, Python 3.15.2 (venv) and 3.13.18. - I found the mismatches by comparing `disasm_rdna2.decode_instruction` with `llvm-mc --disassemble -mcpu=gfx1013` (LLVM 21.1.8) on random instruction words in each encoding family. The encodings and spellings in the new vectors come from `llvm-mc -mcpu=gfx1013 -show-encoding`. On the branch, the same comparison over 1500 words per family shows no special-operand mismatches. `src_lds_direct` in a scalar slot is the one exception: LLVM prints the same name but adds an "invalid register" comment. - `python -B tests/rdna2_tools_check.py TestRdna2Disasm.test_golden_vectors`: on `main` this fails at the first new vector (`eb02007e`: got `v_mov_b32_e32 v0, s235`, expected `... src_shared_base`). On the branch it passes. - `python -B tests/rdna2_tools_check.py`: `Ran 72 tests ... OK (skipped=1)` on 3.15 and 3.13. The skip is `test_llvm_comparison` because `LLVM_LIB` is not set. - All 25 pure-Python checks from the workflow pass. - `ctest --preset dev --no-tests=error -E '_hardware$'` (dev preset, SPIR-V tools on PATH, `-j 4`): 309 passed, 2 skipped (`bvh_wave64_warp` and `wave_shuffle_warp`, exit 77), and 2 timed out under parallel load (`pixel_aot_comparisons_warp` and `pixel_aot_predicate_rounding_warp`). Rerun alone with `-j 1`, those two passed in 11.5 s and 9.2 s. Not run: the Ubuntu LLVM 15 job. I added six lines to the `test_llvm_comparison` fixture (`src_shared_base`, `src_pops_exiting_wave_id`, `src_scc` and `src_lds_direct` as `v_mov_b32_e32` sources, `0.15915494` in `v_add_f32_e32` and `0.15915494309189532` in `v_add_f64`). That job compares them with LLVM 15's disassembly. I checked the same lines with LLVM 21 only. ## Evidence and follow-up The new vectors are instruction encodings produced by `llvm-mc`. No external data is involved. The same comparison found two other disassembler mismatches that this PR does not fix: - VOP1 `v_cvt_u32_f64_e32`, `v_cvt_i32_f64_e32` and `v_cvt_f32_f64_e32` print the 32-bit destination as a pair (`v[66:67]` instead of `v66`). The e64 forms are correct. - `v_interp_mov_f32` prints its parameter as a VGPR (`v0`/`v1`/`v2`) instead of `p10`/`p20`/`p0`. ## 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. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:45:04 +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!842
No description provided.