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

Closed
github-bot wants to merge 1 commit from gh-pr/1301/head into gh-pr/1301/base
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:17 UTC · original
geiyiliyabumo:test/shader-gfx10-opcodes → main · +388 −129 · 4 files · 1 commits · closed without merging

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1301) `geiyiliyabumo:test/shader-gfx10-opcodes` → `main` · +388 −129 · 4 files · 1 commits · closed without merging ## 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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:54 +00:00
github-bot closed this pull request 2026-11-26 04:26:54 +00:00
Author
Owner

@⁠dpalacios69 on GitHub · 2026-11-24 18:26 UTC · original

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.

**@⁠dpalacios69** on GitHub · 2026-11-24 18:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1301#issuecomment-7140651455) 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.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-24 23:09 UTC · original

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).

**@⁠wwwwwwww3333333** on GitHub · 2026-11-24 23:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1301#issuecomment-7147080772) 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).
Author
Owner

@⁠zed6000 on GitHub · 2026-11-25 01:01 UTC · original

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.

**@⁠zed6000** on GitHub · 2026-11-25 01:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1301#issuecomment-7149134111) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1301
No description provided.