shader: align VOP2 opcode table with GFX10/RDNA 2 in disasm_rdna2 #248

Merged
Vonsek merged 4 commits from upstream-pr/251 into main 2026-11-22 06:33:33 +00:00
Vonsek commented 2026-11-21 19:18:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T19:18:40Z.


Change

Align VOP2_OPS in tools/disasm_rdna2.py with the GFX10 / RDNA 2 (gfx1013) ISA opcode table, following up on #245.

Previously, VOP2_OPS mapped pre-GFX10 opcode numbers (for example 0x01 to v_add_f32_e32 instead of v_cndmask_b32_e32, 0x03 to v_subrev_f32_e32 instead of v_add_f32_e32, 0x10 to v_and_b32_e32 instead of v_max_f32_e32, and 0x1b to v_fmac_f32_e32 instead of v_and_b32_e32). It now maps all 22 VOP2 opcodes to their GFX10/RDNA 2 numbers, formats v_cndmask_b32_e32 with its implicit vcc_lo operand, and removes the non-VOP2 v_cvt_pkrtz_f16_f32_e32 entry at 0x2f.

tests/rdna2_tools_check.py:

  • updates the VOP2 golden vectors to GFX10/RDNA 2 encodings (v_cndmask_b32_e32, v_add_f32_e32, v_mul_f32_e32, v_and_b32_e32, v_add_nc_u32_e32, v_fmac_f32_e32);
  • adds all 22 VOP2 instructions to test_llvm_comparison so the Ubuntu Assemble and translate gfx1013 fixtures CI job verifies every opcode and operand against LLVM 15 (llvm-mc -mcpu=gfx1013 / libLLVM).

Verification

Tested on Windows 11 x64, Python 3.12.10, at commit 5c48879:

  • Before updating tools/disasm_rdna2.py, rdna2_tools_check fails on the GFX10 VOP2 vectors:
    ctest --preset dev --no-tests=error -R '^rdna2_tools_check$' -V
    AssertionError: 'v_add_f32_e32' != 'v_cndmask_b32_e32' : Mismatched opcode for 01050602
    1/1 Test #97: rdna2_tools_check ................***Failed    0.82 sec
    
  • After updating tools/disasm_rdna2.py:
    ctest --preset dev --no-tests=error -R '^rdna2_tools_check$' -V
    Ran 19 tests in 0.502s
    OK (skipped=1)
    1/1 Test #97: rdna2_tools_check ................   Passed    0.66 sec
    
    (test_llvm_comparison is skipped locally without LLVM_LIB and runs in the Ubuntu Assemble and translate gfx1013 fixtures CI job.)

Evidence and follow-up

All test vectors are original synthetic encodings and llvm-mc source instructions.

Other opcode tables in tools/disasm_rdna2.py (VOP1_OPS, SOP1_OPS, SOP2_OPS, SOPK_OPS) are left for separate focused follow-ups verified against LLVM 15.

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:6533308205 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/251). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T19:18:40Z. --- ## Change Align `VOP2_OPS` in `tools/disasm_rdna2.py` with the GFX10 / RDNA 2 (`gfx1013`) ISA opcode table, following up on #245. Previously, `VOP2_OPS` mapped pre-GFX10 opcode numbers (for example `0x01` to `v_add_f32_e32` instead of `v_cndmask_b32_e32`, `0x03` to `v_subrev_f32_e32` instead of `v_add_f32_e32`, `0x10` to `v_and_b32_e32` instead of `v_max_f32_e32`, and `0x1b` to `v_fmac_f32_e32` instead of `v_and_b32_e32`). It now maps all 22 VOP2 opcodes to their GFX10/RDNA 2 numbers, formats `v_cndmask_b32_e32` with its implicit `vcc_lo` operand, and removes the non-VOP2 `v_cvt_pkrtz_f16_f32_e32` entry at `0x2f`. `tests/rdna2_tools_check.py`: - updates the VOP2 golden vectors to GFX10/RDNA 2 encodings (`v_cndmask_b32_e32`, `v_add_f32_e32`, `v_mul_f32_e32`, `v_and_b32_e32`, `v_add_nc_u32_e32`, `v_fmac_f32_e32`); - adds all 22 VOP2 instructions to `test_llvm_comparison` so the Ubuntu `Assemble and translate gfx1013 fixtures` CI job verifies every opcode and operand against LLVM 15 (`llvm-mc -mcpu=gfx1013` / `libLLVM`). ## Verification Tested on Windows 11 x64, Python 3.12.10, at commit `5c48879`: - Before updating `tools/disasm_rdna2.py`, `rdna2_tools_check` fails on the GFX10 VOP2 vectors: ```text ctest --preset dev --no-tests=error -R '^rdna2_tools_check$' -V AssertionError: 'v_add_f32_e32' != 'v_cndmask_b32_e32' : Mismatched opcode for 01050602 1/1 Test #97: rdna2_tools_check ................***Failed 0.82 sec ``` - After updating `tools/disasm_rdna2.py`: ```text ctest --preset dev --no-tests=error -R '^rdna2_tools_check$' -V Ran 19 tests in 0.502s OK (skipped=1) 1/1 Test #97: rdna2_tools_check ................ Passed 0.66 sec ``` (`test_llvm_comparison` is skipped locally without `LLVM_LIB` and runs in the Ubuntu `Assemble and translate gfx1013 fixtures` CI job.) ## Evidence and follow-up All test vectors are original synthetic encodings and `llvm-mc` source instructions. Other opcode tables in `tools/disasm_rdna2.py` (`VOP1_OPS`, `SOP1_OPS`, `SOP2_OPS`, `SOPK_OPS`) are left for separate focused follow-ups verified against LLVM 15. ## 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.
upstream-sync closed this pull request 2026-11-24 06:42:02 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:42:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T19:28:17Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79bb63d25c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6007680884 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/251#pullrequestreview-6007680884). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T19:28:17Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `79bb63d25c` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot commented 2026-11-24 06:47:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T19:25:24Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T19:28:20.008746Z 79bb63d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068009131 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/251#issuecomment-7068009131). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T19:25:24Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"79bb63d25c630f5b5a3eba1cb94e469b9d3744fb","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T19:28:20.008746Z">2026-11-21T19:28:20.008746Z</relative-time> | `79bb63d` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Vonsek commented 2026-11-24 06:47:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T19:31:32Z.


Restored 0x2f: v_cvt_pkrtz_f16_f32_e32 in VOP2_OPS and added v_cvt_pkrtz_f16_f32_e32 v3, v1, v2 to the LLVM comparison fixture in tests/rdna2_tools_check.py.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068083148 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/251#issuecomment-7068083148). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T19:31:32Z. --- Restored `0x2f: v_cvt_pkrtz_f16_f32_e32` in `VOP2_OPS` and added `v_cvt_pkrtz_f16_f32_e32 v3, v1, v2` to the LLVM comparison fixture in `tests/rdna2_tools_check.py`.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T19:28:17Z.

Code review location: tools/disasm_rdna2.py; line 192

@@ -168,27 +168,28 @@ def decode_v_reg(reg_id: int) -> str:
 }
 
 VOP2_OPS = {
-    0x01: ("v_add_f32_e32", "Vector add float32"),
-    0x02: ("v_sub_f32_e32", "Vector subtract float32"),
-    0x03: ("v_subrev_f32_e32", "Vector reverse subtract float32"),
-    0x04: ("v_mul_legacy_f32_e32", "Vector multiply zero-preserving float32"),
-    0x05: ("v_mul_f32_e32", "Vector multiply float32"),
-    0x07: ("v_min_f32_e32", "Vector minimum float32"),
-    0x08: ("v_max_f32_e32", "Vector maximum float32"),
-    0x09: ("v_min_i32", "Vector minimum int32"),
-    0x0a: ("v_max_i32", "Vector maximum int32"),
-    0x0b: ("v_min_u32", "Vector minimum uint32"),
-    0x0c: ("v_max_u32", "Vector maximum uint32"),
-    0x0d: ("v_lshrrev_b32_e32", "Vector shift right logical"),
-    0x0e: ("v_ashrrev_i32_e32", "Vector shift right arithmetic"),
-    0x0f: ("v_lshlrev_b32_e32", "Vector shift left logical"),
-    0x10: ("v_and_b32_e32", "Vector bitwise AND"),
-    0x11: ("v_or_b32_e32", "Vector bitwise OR"),
-    0x12: ("v_xor_b32_e32", "Vector bitwise XOR"),
-    0x14: ("v_add_nc_u32_e32", "Vector add uint32 without carry"),
-    0x15: ("v_sub_nc_u32_e32", "Vector sub uint32 without carry"),
-    0x1b: ("v_fmac_f32_e32", "Vector fused multiply-accumulate float32"),
-    0x2f: ("v_cvt_pkrtz_f16_f32_e32", "Pack two float32 into float16 pair (round toward zero)"),
+    0x01: ("v_cndmask_b32_e32", "Vector conditional mask select"),
+    0x03: ("v_add_f32_e32", "Vector add float32"),
+    0x04: ("v_sub_f32_e32", "Vector subtract float32"),
+    0x05: ("v_subrev_f32_e32", "Vector reverse subtract float32"),
+    0x07: ("v_mul_legacy_f32_e32", "Vector multiply zero-preserving float32"),
+    0x08: ("v_mul_f32_e32", "Vector multiply float32"),
+    0x0f: ("v_min_f32_e32", "Vector minimum float32"),
+    0x10: ("v_max_f32_e32", "Vector maximum float32"),
+    0x11: ("v_min_i32_e32", "Vector minimum int32"),
+    0x12: ("v_max_i32_e32", "Vector maximum int32"),
+    0x13: ("v_min_u32_e32", "Vector minimum uint32"),
+    0x14: ("v_max_u32_e32", "Vector maximum uint32"),
+    0x16: ("v_lshrrev_b32_e32", "Vector shift right logical"),
+    0x18: ("v_ashrrev_i32_e32", "Vector shift right arithmetic"),
+    0x1a: ("v_lshlrev_b32_e32", "Vector shift left logical"),
+    0x1b: ("v_and_b32_e32", "Vector bitwise AND"),
+    0x1c: ("v_or_b32_e32", "Vector bitwise OR"),
+    0x1d: ("v_xor_b32_e32", "Vector bitwise XOR"),
+    0x25: ("v_add_nc_u32_e32", "Vector add uint32 without carry"),
+    0x26: ("v_sub_nc_u32_e32", "Vector sub uint32 without carry"),
+    0x27: ("v_subrev_nc_u32_e32", "Vector reverse sub uint32 without carry"),
+    0x2b: ("v_fmac_f32_e32", "Vector fused multiply-accumulate float32"),

P2 Badge Restore the valid GFX10 packed-conversion opcode

For gfx1013 bytes 0105065e, LLVM 20 and the parent commit both decode v_cvt_pkrtz_f16_f32_e32 v3, v1, v2, but the updated disassembler instead emits v_vop2_2f v3, v1, v2. Opcode 0x2f remains a valid GFX10 VOP2 instruction, also classified as such in docs/coverage/gfx1013.tsv:1281, so removing its mapping regresses disassembly of half-float packing instructions used before color exports. Retain the mapping and include this instruction in the LLVM comparison fixture.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4654581703 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/251#discussion_r4654581703). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T19:28:17Z. **Code review location:** `tools/disasm_rdna2.py`; line 192 ~~~~diff @@ -168,27 +168,28 @@ def decode_v_reg(reg_id: int) -> str: } VOP2_OPS = { - 0x01: ("v_add_f32_e32", "Vector add float32"), - 0x02: ("v_sub_f32_e32", "Vector subtract float32"), - 0x03: ("v_subrev_f32_e32", "Vector reverse subtract float32"), - 0x04: ("v_mul_legacy_f32_e32", "Vector multiply zero-preserving float32"), - 0x05: ("v_mul_f32_e32", "Vector multiply float32"), - 0x07: ("v_min_f32_e32", "Vector minimum float32"), - 0x08: ("v_max_f32_e32", "Vector maximum float32"), - 0x09: ("v_min_i32", "Vector minimum int32"), - 0x0a: ("v_max_i32", "Vector maximum int32"), - 0x0b: ("v_min_u32", "Vector minimum uint32"), - 0x0c: ("v_max_u32", "Vector maximum uint32"), - 0x0d: ("v_lshrrev_b32_e32", "Vector shift right logical"), - 0x0e: ("v_ashrrev_i32_e32", "Vector shift right arithmetic"), - 0x0f: ("v_lshlrev_b32_e32", "Vector shift left logical"), - 0x10: ("v_and_b32_e32", "Vector bitwise AND"), - 0x11: ("v_or_b32_e32", "Vector bitwise OR"), - 0x12: ("v_xor_b32_e32", "Vector bitwise XOR"), - 0x14: ("v_add_nc_u32_e32", "Vector add uint32 without carry"), - 0x15: ("v_sub_nc_u32_e32", "Vector sub uint32 without carry"), - 0x1b: ("v_fmac_f32_e32", "Vector fused multiply-accumulate float32"), - 0x2f: ("v_cvt_pkrtz_f16_f32_e32", "Pack two float32 into float16 pair (round toward zero)"), + 0x01: ("v_cndmask_b32_e32", "Vector conditional mask select"), + 0x03: ("v_add_f32_e32", "Vector add float32"), + 0x04: ("v_sub_f32_e32", "Vector subtract float32"), + 0x05: ("v_subrev_f32_e32", "Vector reverse subtract float32"), + 0x07: ("v_mul_legacy_f32_e32", "Vector multiply zero-preserving float32"), + 0x08: ("v_mul_f32_e32", "Vector multiply float32"), + 0x0f: ("v_min_f32_e32", "Vector minimum float32"), + 0x10: ("v_max_f32_e32", "Vector maximum float32"), + 0x11: ("v_min_i32_e32", "Vector minimum int32"), + 0x12: ("v_max_i32_e32", "Vector maximum int32"), + 0x13: ("v_min_u32_e32", "Vector minimum uint32"), + 0x14: ("v_max_u32_e32", "Vector maximum uint32"), + 0x16: ("v_lshrrev_b32_e32", "Vector shift right logical"), + 0x18: ("v_ashrrev_i32_e32", "Vector shift right arithmetic"), + 0x1a: ("v_lshlrev_b32_e32", "Vector shift left logical"), + 0x1b: ("v_and_b32_e32", "Vector bitwise AND"), + 0x1c: ("v_or_b32_e32", "Vector bitwise OR"), + 0x1d: ("v_xor_b32_e32", "Vector bitwise XOR"), + 0x25: ("v_add_nc_u32_e32", "Vector add uint32 without carry"), + 0x26: ("v_sub_nc_u32_e32", "Vector sub uint32 without carry"), + 0x27: ("v_subrev_nc_u32_e32", "Vector reverse sub uint32 without carry"), + 0x2b: ("v_fmac_f32_e32", "Vector fused multiply-accumulate float32"), ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Restore the valid GFX10 packed-conversion opcode** For gfx1013 bytes `0105065e`, LLVM 20 and the parent commit both decode `v_cvt_pkrtz_f16_f32_e32 v3, v1, v2`, but the updated disassembler instead emits `v_vop2_2f v3, v1, v2`. Opcode `0x2f` remains a valid GFX10 VOP2 instruction, also classified as such in `docs/coverage/gfx1013.tsv:1281`, so removing its mapping regresses disassembly of half-float packing instructions used before color exports. Retain the mapping and include this instruction in the LLVM comparison fixture. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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!248
No description provided.