Shaders: align GFX10 opcode tables with RDNA2 ISA and add synthetic tests #1301

Closed
geiyiliyabumo wants to merge 1 commit from upstream-pr/1301 into main
geiyiliyabumo commented 2026-11-24 17:17:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T17:17:11Z.


Summary

Audits all 19 GFX10 opcode tables in \crates/victory-shader/src/gfx10/opcodes.rs\ against AMD's RDNA2 ISA specification and cross-checks synthetic instruction words with LLVM \gfx1030:

  • Fixes 2 fused legacy F32 mnemonics, adds 31 missing RDNA2 encodings (VOP3 interpolation, signed packed dot product, MIMG), and removes 105 non-RDNA2 entries.
  • Updates nearby decoder/field/printer consumers (\gfx10/mod.rs, \gfx10/fields.rs, \gfx10/sp3.rs) to exclude 9 compact-only VOP3 aliases, bound EXP lookup, handle packed gathers, VOP3 interpolation operands, and independent _g16/\16\ packing (note: overlaps \ ields.rs\ in #1209).
  • Adds 10 deterministic synthetic unit tests covering all table entries, gaps, field limits, alias ranges, operand widths, literal boundaries, and disassembly.

Verification

  • \cargo test -p victory-shader --lib gfx10::opcodes\ ? 11 passed, 0 failed
  • \cargo test -p victory-shader --lib gfx10::\ ? 22 passed, 0 failed
  • \cargo clippy -p victory-shader --all-targets -- -D warnings\ ? clean
  • \cargo xtask policy\ ? 154 files ok

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587410903 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1301). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T17:17:11Z. --- ## Summary Audits all 19 GFX10 opcode tables in \crates/victory-shader/src/gfx10/opcodes.rs\ against AMD's RDNA2 ISA specification and cross-checks synthetic instruction words with LLVM \gfx1030\: - Fixes 2 fused legacy F32 mnemonics, adds 31 missing RDNA2 encodings (VOP3 interpolation, signed packed dot product, MIMG), and removes 105 non-RDNA2 entries. - Updates nearby decoder/field/printer consumers (\gfx10/mod.rs\, \gfx10/fields.rs\, \gfx10/sp3.rs\) to exclude 9 compact-only VOP3 aliases, bound EXP lookup, handle packed gathers, VOP3 interpolation operands, and independent \_g16\/\16\ packing (note: overlaps \ ields.rs\ in #1209). - Adds 10 deterministic synthetic unit tests covering all table entries, gaps, field limits, alias ranges, operand widths, literal boundaries, and disassembly. ## Verification - \cargo test -p victory-shader --lib gfx10::opcodes\ ? 11 passed, 0 failed - \cargo test -p victory-shader --lib gfx10::\ ? 22 passed, 0 failed - \cargo clippy -p victory-shader --all-targets -- -D warnings\ ? clean - \cargo xtask policy\ ? 154 files ok *AI-assisted; synthetic tests only, no game files.*
dpalacios69 commented 2026-11-24 19:04:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dpalacios69 on 2026-11-24T18:26:35Z.


Independent check on Linux of head cacb8d2, merged onto current main (ffe310e; a fast-forward): cargo test -p victory-shader --locked passes (106 passed, 0 failed, 1 ignored). The 10 test(s) it adds run on Linux and pass. cargo clippy -p victory-shader --all-targets -- -D warnings shows nothing of its own, only the two unused-import errors in emit/mod.rs that main already has on Linux. No GPU run. AI-assisted; no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140651455 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1301#issuecomment-7140651455). Originally posted by [dpalacios69](https://github.com/dpalacios69) on 2026-11-24T18:26:35Z. --- Independent check on Linux of head `cacb8d2`, merged onto current `main` (`ffe310e`; a fast-forward): `cargo test -p victory-shader --locked` passes (106 passed, 0 failed, 1 ignored). The 10 test(s) it adds run on Linux and pass. `cargo clippy -p victory-shader --all-targets -- -D warnings` shows nothing of its own, only the two unused-import errors in `emit/mod.rs` that `main` already has on Linux. No GPU run. AI-assisted; no game data.
catminou4 commented 2026-11-24 21:02:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:09:42Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 106 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests.

Aligns the GFX10 opcode tables with the RDNA2 ISA and adds synthetic decode tests: table reachability/unique mnemonics, VOP3 aliases only where a long form exists, older-generation opcodes reserved, fused/signed dot decode, VOP3 interpolation fields, SOPK/VOP2 literal boundaries, buffer widths across split fields. Exactly the kind of table audit the translator needs.

<!-- greyfinch-sync:Marvisak/VIctory:review:6046555828 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1301#pullrequestreview-6046555828). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:09:42Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 106 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests. Aligns the GFX10 opcode tables with the RDNA2 ISA and adds synthetic decode tests: table reachability/unique mnemonics, VOP3 aliases only where a long form exists, older-generation opcodes reserved, fused/signed dot decode, VOP3 interpolation fields, SOPK/VOP2 literal boundaries, buffer widths across split fields. Exactly the kind of table audit the translator needs.
upstream-sync closed this pull request 2026-11-24 23:04:29 +00:00
wwwwwwww3333333 commented 2026-11-25 00:06:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-24T23:09:33Z.


This PR (head cacb8d2) merges cleanly onto the new main (70564ae0) but breaks two of main's new tests there: emit::semantics_tests::arithmetic_matches_the_hardware and output_multipliers_give_positive_zero (RX 6750 XT, Windows 11, Rust 1.98.1 MSVC; 217 passed, 2 failed; main alone 209/209).

What they report:

v_mov_b32 v5, v3; v_fmac_legacy_f32 v5, v1, v2: not lowered: GFX10 code at 0x44: v_fmac_legacy_f32 is not supported
v_fma_legacy_f32 v5, v1, v2, v3: not lowered: GFX10 code at 0x44: v_fma_legacy_f32 is not supported
v_fma_legacy_f32 v5, v1, v2, v3 mul:2: not lowered: ...
? v5, v1, v2, v3: not lowered: GFX10 code at 0x3c: unknown opcode is not supported

The table renames VOP2 0x006 v_mac_legacy_f32 to v_fmac_legacy_f32 and VOP3 0x140 v_mad_legacy_f32 to v_fma_legacy_f32. Those are the RDNA2 names, but the lowering still matches on the old mnemonics, so those instructions stop lowering. The ? lines come from encodings the table no longer has. Main's new semantics tests check exactly these instructions against the console's float mode.

So after a rebase, the lowering (and the semantics tests' expectations) would need to follow the renames. That includes deciding whether the fma/fmac names should lower as fused, which is what the RDNA2 names say and which main's README now calls "fused multiply-adds follow the host GPU".

Unit tests only, no game files. AI-assisted (Claude; I ran it on my machine).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147080772 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1301#issuecomment-7147080772). Originally posted by [wwwwwwww3333333](https://github.com/wwwwwwww3333333) on 2026-11-24T23:09:33Z. --- This PR (head cacb8d2) merges cleanly onto the new main (70564ae0) but breaks two of main's new tests there: `emit::semantics_tests::arithmetic_matches_the_hardware` and `output_multipliers_give_positive_zero` (RX 6750 XT, Windows 11, Rust 1.98.1 MSVC; 217 passed, 2 failed; main alone 209/209). What they report: ``` v_mov_b32 v5, v3; v_fmac_legacy_f32 v5, v1, v2: not lowered: GFX10 code at 0x44: v_fmac_legacy_f32 is not supported v_fma_legacy_f32 v5, v1, v2, v3: not lowered: GFX10 code at 0x44: v_fma_legacy_f32 is not supported v_fma_legacy_f32 v5, v1, v2, v3 mul:2: not lowered: ... ? v5, v1, v2, v3: not lowered: GFX10 code at 0x3c: unknown opcode is not supported ``` The table renames VOP2 0x006 `v_mac_legacy_f32` to `v_fmac_legacy_f32` and VOP3 0x140 `v_mad_legacy_f32` to `v_fma_legacy_f32`. Those are the RDNA2 names, but the lowering still matches on the old mnemonics, so those instructions stop lowering. The `?` lines come from encodings the table no longer has. Main's new semantics tests check exactly these instructions against the console's float mode. So after a rebase, the lowering (and the semantics tests' expectations) would need to follow the renames. That includes deciding whether the `fma`/`fmac` names should lower as fused, which is what the RDNA2 names say and which main's README now calls "fused multiply-adds follow the host GPU". Unit tests only, no game files. AI-assisted (Claude; I ran it on my machine).
zed6000 commented 2026-11-25 01:08:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-25T01:01:51Z.


Measured offline on the title's shaders, as in #1247 (victory translate --validate --list over shaders.rpf 1.0.2.1, dxil.dll 1.8.2502, compared program by program). This PR stops thousands of programs that validate today from translating:

Merged onto Gained Lost The lost programs now fail with
its base ffe310e 0 6,156 "unsupported: unknown opcode" 5,447, "emit: v_fma_legacy_f32" 706
main 70564ae 0 8,712 "unsupported: unknown opcode" 8,569 (with the other) and "emit: v_fma_legacy_f32" 956

On 70564ae the losses cover every stage: 5,893 pixel, 1,475 compute, 999 mesh and 202 vertex programs. cargo test -p victory-shader --lib passes (130/0 on ffe310e), so the synthetic tests don't show it. The title's code uses encodings that the updated tables no longer name, or names differently.

The v_fma_legacy_f32 hits suggest that at least one opcode number now maps to a different instruction than before, one the lowering doesn't handle. The "unknown opcode" hits suggest that entries the title relies on were dropped or moved. Before merging, this probably needs a check of which opcode numbers changed meaning against code the title actually runs. The console's GFX10 encodings may not match the RDNA2 ISA document's table in every slot. Offline counts only; no program names or data, per the asset policy.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149134111 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1301#issuecomment-7149134111). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-25T01:01:51Z. --- Measured offline on the title's shaders, as in #1247 (`victory translate --validate --list` over `shaders.rpf` 1.0.2.1, dxil.dll 1.8.2502, compared program by program). **This PR stops thousands of programs that validate today from translating:** | Merged onto | Gained | Lost | The lost programs now fail with | |---|---|---|---| | its base `ffe310e` | 0 | **6,156** | "unsupported: unknown opcode" 5,447, "emit: v_fma_legacy_f32" 706 | | main `70564ae` | 0 | **8,712** | "unsupported: unknown opcode" 8,569 (with the other) and "emit: v_fma_legacy_f32" 956 | On `70564ae` the losses cover every stage: 5,893 pixel, 1,475 compute, 999 mesh and 202 vertex programs. `cargo test -p victory-shader --lib` passes (130/0 on `ffe310e`), so the synthetic tests don't show it. The title's code uses encodings that the updated tables no longer name, or names differently. The `v_fma_legacy_f32` hits suggest that at least one opcode number now maps to a different instruction than before, one the lowering doesn't handle. The "unknown opcode" hits suggest that entries the title relies on were dropped or moved. Before merging, this probably needs a check of which opcode numbers changed meaning against code the title actually runs. The console's GFX10 encodings may not match the RDNA2 ISA document's table in every slot. Offline counts only; no program names or data, per the asset policy.

Pull request closed

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
Marvisak/VIctory!1301
No description provided.