shader: pin the opcode-name resolution with unit tests #480

Closed
AnastasisKon wants to merge 1 commit from upstream-pr/480 into main
AnastasisKon commented 2026-11-27 21:59:15 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T21:59:15Z.


What this changes

Refs #477.

name(encoding, opcode) in crates/victory-shader/src/gfx10 resolves an instruction's name, and three things read it: apps/victory's survey counts opcodes it cannot name, refusal messages quote names, and corpus comparisons compare them. opcodes.rs had one test; a table edit can rename an instruction with nothing failing.

gfx10/opcodes_tests.rs (declared under cfg(test), so the build hash is unchanged) pins:

  • one name per encoding table — SOP2, SOPK, SOP1, SOPC, SOPP, SMEM, VOP2, VOP1, VOPC, VOP3, VOP3P, VINTRP, DS, MUBUF, MTBUF, MIMG, FLAT, GLOBAL, SCRATCH — and EXP naming itself whatever its opcode field holds;
  • VOP3 carrying the VOPC, VOP2 and VOP1 opcodes at their fixed bases (0x000–0x0ff, 0x100–0x13f, 0x180–0x1ff), with VOP3's own table deciding 0x140–0x17f — 0x140 is RDNA2's v_fma_legacy_f32 (#321);
  • opcodes past the end of a table resolving to no name rather than to a neighbour's.

No behaviour change, no new dependencies, synthetic opcodes only.

How it was tested

  • cargo test -p victory-shader: 405 passed, 0 failed, 3 ignored (the new module included).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: no warnings on this tree.
  • cargo xtask policy: 398 files ok.
  • Shader corpus sweep: not applicable — this changes no translation, only tests.
  • Ran the game: not needed (test-only).

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md: none added; the 0x140 case matches #321's finding, which is already marked in the table
  • New diagnostics are behind a VICTORY_* variable and documented: none added
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5533632547 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/480). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T21:59:15Z. --- ## What this changes Refs #477. `name(encoding, opcode)` in `crates/victory-shader/src/gfx10` resolves an instruction's name, and three things read it: `apps/victory`'s survey counts opcodes it cannot name, refusal messages quote names, and corpus comparisons compare them. `opcodes.rs` had one test; a table edit can rename an instruction with nothing failing. `gfx10/opcodes_tests.rs` (declared under `cfg(test)`, so the build hash is unchanged) pins: - one name per encoding table — SOP2, SOPK, SOP1, SOPC, SOPP, SMEM, VOP2, VOP1, VOPC, VOP3, VOP3P, VINTRP, DS, MUBUF, MTBUF, MIMG, FLAT, GLOBAL, SCRATCH — and EXP naming itself whatever its opcode field holds; - VOP3 carrying the VOPC, VOP2 and VOP1 opcodes at their fixed bases (0x000–0x0ff, 0x100–0x13f, 0x180–0x1ff), with VOP3's own table deciding 0x140–0x17f — `0x140` is RDNA2's `v_fma_legacy_f32` (#321); - opcodes past the end of a table resolving to no name rather than to a neighbour's. No behaviour change, no new dependencies, synthetic opcodes only. ## How it was tested - [x] `cargo test -p victory-shader`: 405 passed, 0 failed, 3 ignored (the new module included). - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`: no warnings on this tree. - [x] `cargo xtask policy`: 398 files ok. - [x] Shader corpus sweep: not applicable — this changes no translation, only tests. - [ ] Ran the game: not needed (test-only). ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md: none added; the `0x140` case matches #321's finding, which is already marked in the table - [x] New diagnostics are behind a `VICTORY_*` variable and documented: none added
AnastasisKon commented 2026-11-27 22:19:03 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T22:19:03Z.


Closing as a duplicate of #498, which pins the same issue #477 with more: it walks every table entry rather than sampling one name per encoding, and it pins the sortedness name()'s binary search depends on, which this PR did not cover. Everything this branch covered (one name per encoding, the VOP3 fixed bases, past-the-end opcodes resolving to None) is covered there too, so nothing is lost.

The branch stays as it is; reopen if #498 changes direction.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229223092 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/480#issuecomment-7229223092). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T22:19:03Z. --- Closing as a duplicate of #498, which pins the same issue #477 with more: it walks every table entry rather than sampling one name per encoding, and it pins the sortedness `name()`'s binary search depends on, which this PR did not cover. Everything this branch covered (one name per encoding, the VOP3 fixed bases, past-the-end opcodes resolving to `None`) is covered there too, so nothing is lost. The branch stays as it is; reopen if #498 changes direction.

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
LakshanSivakumar/Native-Victory-macOS!480
No description provided.