shader: decode SOPC scalar comparisons in disasm_rdna2 #426

Merged
Jawschamp merged 1 commit from upstream-pr/432 into main 2026-11-22 02:26:40 +00:00
Jawschamp commented 2026-11-22 02:17:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jawschamp on 2026-11-22T02:17:57Z.


Change

tools/disasm_rdna2.py did not recognize SOPC encodings ([31:23] == 0b101111110). Those 32-bit words fell through to the SOPK prefix check and decoded as unknown SOPK ops. For example, s_cmp_eq_i32 s0, s1 (000100bf) came out as s_sopk_1e s0, 0x100.

This change decodes the GFX10 / RDNA 2 SOPC table used by gfx1013:

  • s_cmp_{eq,lg,gt,ge,lt,le}_{i32,u32}
  • s_bitcmp{0,1}_b32 and s_bitcmp{0,1}_b64
  • s_cmp_{eq,lg}_u64

64-bit operands print as SGPR pairs or the named specials (s[0:1], exec, vcc, null). A literal source consumes the following dword so the next instruction stays aligned. The SOPK prefix check now also excludes the SOPC encoding as a backstop.

No issue tracks this. It follows the same disasm_rdna2 line as #263, #264 and #245, and does not touch the VOP2 table in open #251.

Verification

Commit e0081e8 on shader/decode-sopc, based on origin/main at c2fc84c after a rebase. Linux host, Python 3.13.5. LLVM 15 is not available on this Debian Trixie box, so the optional LLVM comparison in rdna2_tools_check was skipped (the same skip as on the Python-only Linux CI job). Windows C++, HLSL, WARP and hardware checks were not run locally.

./out/pe-env/bin/python -B tests/rdna2_tools_check.py
Ran 27 tests in 0.280s
OK (skipped=1)

The skipped test is test_llvm_comparison, which now also lists the new SOPC mnemonics. The Ubuntu pixel-binary job should assemble those with LLVM 15 (llvm-mc -mcpu=gfx1013) and compare opcodes against libLLVM-15.so.1.

The rest of the platform-independent Python suite also passed:

./out/pe-env/bin/python -B tests/script_state_check.py
./out/pe-env/bin/python -B tests/bcpack_check.py
./out/pe-env/bin/python -B tests/form_coverage_check.py
./out/pe-env/bin/python -B tests/resource_ranges_check.py
./out/pe-env/bin/python -B tests/dxcontainer_part_offsets_check.py
./out/pe-env/bin/python -B tests/layout_chunks_check.py
./out/pe-env/bin/python -B tests/dependency_paths_check.py
./out/pe-env/bin/python -B tests/intake/paths_check.py
./out/pe-env/bin/python -B tests/shader_probe_check.py
./out/pe-env/bin/python -B tests/dxil_retarget_check.py
./out/pe-env/bin/python -B tests/pso_readiness_check.py
./out/pe-env/bin/python -B tests/docs_links_check.py
./out/pe-env/bin/python -B tests/bidi_controls_check.py
./out/pe-env/bin/python -B tests/gpu_report_format_check.py

All of those commands exited 0. git diff --check was clean.

Evidence and follow-up

Golden encodings follow LLVM's GFX10 SOPC layout (Inst{31-23}=0x17e, opcode in bits 22–16). Opcode numbers match LLVM's SOPC_Real_gfx10 assignments. Fixtures are source-owned hex vectors and a two-instruction stream that places s_endpgm after an 8-byte SOPC-with-literal.

A useful next step, kept out of this PR, is decoding VOPC (currently swallowed by the VOP2 catch-all) after #251 lands, and then VOP3, whose 64-bit encodings are still returned as a 4-byte unrecognized word and desynchronize the rest of a binary shader.

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 public capability or build step changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6537307917 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/432). Originally posted by [Jawschamp](https://github.com/Jawschamp) on 2026-11-22T02:17:57Z. --- ## Change `tools/disasm_rdna2.py` did not recognize SOPC encodings (`[31:23] == 0b101111110`). Those 32-bit words fell through to the SOPK prefix check and decoded as unknown SOPK ops. For example, `s_cmp_eq_i32 s0, s1` (`000100bf`) came out as `s_sopk_1e s0, 0x100`. This change decodes the GFX10 / RDNA 2 SOPC table used by `gfx1013`: - `s_cmp_{eq,lg,gt,ge,lt,le}_{i32,u32}` - `s_bitcmp{0,1}_b32` and `s_bitcmp{0,1}_b64` - `s_cmp_{eq,lg}_u64` 64-bit operands print as SGPR pairs or the named specials (`s[0:1]`, `exec`, `vcc`, `null`). A `literal` source consumes the following dword so the next instruction stays aligned. The SOPK prefix check now also excludes the SOPC encoding as a backstop. No issue tracks this. It follows the same `disasm_rdna2` line as #263, #264 and #245, and does not touch the VOP2 table in open #251. ## Verification Commit `e0081e8` on `shader/decode-sopc`, based on `origin/main` at `c2fc84c` after a rebase. Linux host, Python 3.13.5. LLVM 15 is not available on this Debian Trixie box, so the optional LLVM comparison in `rdna2_tools_check` was skipped (the same skip as on the Python-only Linux CI job). Windows C++, HLSL, WARP and hardware checks were not run locally. ```text ./out/pe-env/bin/python -B tests/rdna2_tools_check.py Ran 27 tests in 0.280s OK (skipped=1) ``` The skipped test is `test_llvm_comparison`, which now also lists the new SOPC mnemonics. The Ubuntu `pixel-binary` job should assemble those with LLVM 15 (`llvm-mc -mcpu=gfx1013`) and compare opcodes against `libLLVM-15.so.1`. The rest of the platform-independent Python suite also passed: ```text ./out/pe-env/bin/python -B tests/script_state_check.py ./out/pe-env/bin/python -B tests/bcpack_check.py ./out/pe-env/bin/python -B tests/form_coverage_check.py ./out/pe-env/bin/python -B tests/resource_ranges_check.py ./out/pe-env/bin/python -B tests/dxcontainer_part_offsets_check.py ./out/pe-env/bin/python -B tests/layout_chunks_check.py ./out/pe-env/bin/python -B tests/dependency_paths_check.py ./out/pe-env/bin/python -B tests/intake/paths_check.py ./out/pe-env/bin/python -B tests/shader_probe_check.py ./out/pe-env/bin/python -B tests/dxil_retarget_check.py ./out/pe-env/bin/python -B tests/pso_readiness_check.py ./out/pe-env/bin/python -B tests/docs_links_check.py ./out/pe-env/bin/python -B tests/bidi_controls_check.py ./out/pe-env/bin/python -B tests/gpu_report_format_check.py ``` All of those commands exited 0. `git diff --check` was clean. ## Evidence and follow-up Golden encodings follow LLVM's GFX10 SOPC layout (`Inst{31-23}=0x17e`, opcode in bits 22–16). Opcode numbers match LLVM's `SOPC_Real_gfx10` assignments. Fixtures are source-owned hex vectors and a two-instruction stream that places `s_endpgm` after an 8-byte SOPC-with-literal. A useful next step, kept out of this PR, is decoding VOPC (currently swallowed by the VOP2 catch-all) after #251 lands, and then VOP3, whose 64-bit encodings are still returned as a 4-byte unrecognized word and desynchronize the rest of a binary shader. ## 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. (No public capability or build step 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:01 +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!426
No description provided.