Skip to content

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

Closed
geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:test/shader-gfx10-opcodes
Closed

geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:test/shader-gfx10-opcodes

Conversation

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

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 Shaders: fix GFX10 independent a16/g16 gradient dword packing in fields.rs with 21 tests #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

Copy link
Copy Markdown
Contributor

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Marvisak Marvisak closed this Nov 24, 2026
@wwwwwwww3333333

Copy link
Copy Markdown
Contributor

This PR (head cacb8d2) merges cleanly onto the new main (70564ae) 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

zed6000 commented Nov 25, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants