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

Closed
github-bot wants to merge 1 commit from github-bot/gh-480 into main AGit
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 21:59 UTC · original
AnastasisKon:vibe/opcode-name-tests-4f9c68 → main · +61 −0 · 2 files · 1 commits · closed without merging

What this changes

Refs #481.

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
**@⁠AnastasisKon** on GitHub · 2026-11-27 21:59 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/480) `AnastasisKon:vibe/opcode-name-tests-4f9c68` → `main` · +61 −0 · 2 files · 1 commits · closed without merging ## What this changes Refs #481. `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
name() resolves each encoding's table by binary search and remaps VOP3's
fixed bases (0x000-0x0ff VOPC, 0x100-0x13f VOP2, 0x180-0x1ff VOP1); opcodes.rs
had one test. Add gfx10/opcodes_tests.rs (declared under cfg(test), so the
build hash is unchanged) pinning one name per encoding, the VOP3 base
remapping, and opcodes outside a table resolving to None.

Refs #477
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:59:41 +00:00
github-bot closed this pull request 2026-11-27 22:23:04 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 22:19 UTC · original

Closing as a duplicate of #502, which pins the same issue #481 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 #502 changes direction.

**@⁠AnastasisKon** on GitHub · 2026-11-27 22:19 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/480#issuecomment-7229223092) Closing as a duplicate of #502, which pins the same issue #481 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 #502 changes direction.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.