shader: pin the GFX10 opcode-name resolution with unit tests (#477) #498

Merged
AnastasisKon merged 1 commit from upstream-pr/498 into main 2026-11-28 01:36:46 +00:00
AnastasisKon commented 2026-11-27 22:18:20 +00:00 (Migrated from github.com)

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


What this changes

Refs #477. Test-only, in crates/victory-shader/src/gfx10/mod.rs. name(encoding, opcode) was untested, so a table edit could silently rename an instruction; the survey's unnamed-opcode counts and refusal messages read the same names. Pinned now:

  • every entry of all 18 direct tables (SOP2…SCRATCH) resolves to its own name;
  • tables are strictly sorted (the resolver binary-searches them);
  • an opcode past a table's end (and u16::MAX) resolves to no name, not a neighbour's;
  • EXP names itself "exp" whatever its opcode field holds;
  • the VOP3 encoding resolves VOPC at 0x000–0x0ff, VOP2 at 0x100–0x13f, VOP1 at 0x180–0x1ff via those tables, and its own table elsewhere — 0x140 = v_fma_legacy_f32 (#321) — with the invariant that no VOP3-table entry sits in a shadowed base range.

Synthetic opcodes only; no game data, no behaviour change, no new dependencies.

How it was tested

  • cargo test -p victory-shader — 406 passed (incl. the 4 new gfx10::tests), 0 failed
  • cargo test -p victory-hle -p victory -p victory-gpu -p xtask — pass (RC=0)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — pass (RC=0, 0 errors)
  • cargo xtask policy — pass (398 files ok)
  • Corpus sweep: not applicable (no translator change); game run: not needed (test-only)

Checklist

  • No game files, game code, disassembly listings or SDK files are included (table names come from Mesa's public opcode list, already in the repo)
  • Guesses about undocumented console behaviour — n/a
  • New diagnostics behind a VICTORY_* variable — n/a, none added
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5533821052 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/498). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T22:18:20Z. --- ## What this changes Refs #477. Test-only, in `crates/victory-shader/src/gfx10/mod.rs`. `name(encoding, opcode)` was untested, so a table edit could silently rename an instruction; the survey's unnamed-opcode counts and refusal messages read the same names. Pinned now: - every entry of all 18 direct tables (SOP2…SCRATCH) resolves to its own name; - tables are strictly sorted (the resolver binary-searches them); - an opcode past a table's end (and `u16::MAX`) resolves to no name, not a neighbour's; - EXP names itself `"exp"` whatever its opcode field holds; - the VOP3 encoding resolves VOPC at 0x000–0x0ff, VOP2 at 0x100–0x13f, VOP1 at 0x180–0x1ff via those tables, and its own table elsewhere — `0x140` = `v_fma_legacy_f32` (#321) — with the invariant that no VOP3-table entry sits in a shadowed base range. Synthetic opcodes only; no game data, no behaviour change, no new dependencies. ## How it was tested - [x] `cargo test -p victory-shader` — 406 passed (incl. the 4 new `gfx10::tests`), 0 failed - [x] `cargo test -p victory-hle -p victory -p victory-gpu -p xtask` — pass (RC=0) - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — pass (RC=0, 0 errors) - [x] `cargo xtask policy` — pass (398 files ok) - [x] Corpus sweep: not applicable (no translator change); game run: not needed (test-only) ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included (table names come from Mesa's public opcode list, already in the repo) - [x] Guesses about undocumented console behaviour — n/a - [x] New diagnostics behind a `VICTORY_*` variable — n/a, none added
AnastasisKon commented 2026-11-27 22:19:02 +00:00 (Migrated from github.com)

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


Two pull requests pin #477 — this one and #480 (vibe/opcode-name-tests-4f9c68, opened 19 minutes earlier). Both are test-only and green. I have closed #480 and kept this one, because it pins more: every_table_entry_resolves_to_its_own_name walks the tables rather than sampling them, and tables_are_sorted_so_the_binary_search_finds_them pins the invariant name()'s binary search actually depends on, which #480 did not cover at all.

Two things worth fixing here before it lands:

  1. flat_offsets_ignore_bit_eleven is a second subject — FLAT offsets are not opcode names — and CONTRIBUTING asks for one change per pull request. It is a good test; it would be a fine PR of its own, or could join a fields suite (gfx10/fields.rs has no tests at all, and offset decoding is where that test belongs).
  2. This crate keeps its tests in sibling files — ir_tests.rs, range_tests.rs, gfx_refusal_tests.rs, emit/lockstep_tests.rs — rather than inline, so gfx10/opcodes_tests.rs would match the neighbourhood. Style only; the module is declared under cfg(test), so either way the build hash is unchanged.

For reference, the coverage #480 had that is now only here: one name per encoding table (19 encodings, EXP ignoring its opcode field), the VOP3 bases for VOPC/VOP2/VOP1 with 0x140 as v_fma_legacy_f32, and past-the-end opcodes resolving to None. All three are covered by this PR's tests, which is why closing #480 loses nothing.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229222726 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/498#issuecomment-7229222726). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T22:19:02Z. --- Two pull requests pin #477 — this one and #480 (`vibe/opcode-name-tests-4f9c68`, opened 19 minutes earlier). Both are test-only and green. I have closed #480 and kept this one, because it pins more: `every_table_entry_resolves_to_its_own_name` walks the tables rather than sampling them, and `tables_are_sorted_so_the_binary_search_finds_them` pins the invariant `name()`'s binary search actually depends on, which #480 did not cover at all. Two things worth fixing here before it lands: 1. `flat_offsets_ignore_bit_eleven` is a second subject — FLAT offsets are not opcode names — and CONTRIBUTING asks for one change per pull request. It is a good test; it would be a fine PR of its own, or could join a `fields` suite (`gfx10/fields.rs` has no tests at all, and offset decoding is where that test belongs). 2. This crate keeps its tests in sibling files — `ir_tests.rs`, `range_tests.rs`, `gfx_refusal_tests.rs`, `emit/lockstep_tests.rs` — rather than inline, so `gfx10/opcodes_tests.rs` would match the neighbourhood. Style only; the module is declared under `cfg(test)`, so either way the build hash is unchanged. For reference, the coverage #480 had that is now only here: one name per encoding table (19 encodings, EXP ignoring its opcode field), the VOP3 bases for VOPC/VOP2/VOP1 with `0x140` as `v_fma_legacy_f32`, and past-the-end opcodes resolving to `None`. All three are covered by this PR's tests, which is why closing #480 loses nothing.
Olima34 commented 2026-11-28 01:36:42 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T01:36:42Z.

Review: APPROVED


Check report (helping the maintainer clear the queue):

  • CI: check and macos-scripts green on the current head.
  • Read: the whole diff (tests only, in the existing #[cfg(test)] module). Every GFX10 opcode table is sorted and resolves to its own names. No translator code changes.
  • Local check: current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#397 #399 #422 #467 #471 #475 #479 #481 #486 #489 #494 #498 #505 #511). On it, the victory-gpu (arm64), victory-shader, victory-backend, victory-metal and victory tests pass, as do the macOS script tests (rustup-path.sh, run-summary-compare.sh, run-summary.sh --self-test), Windows clippy (-D warnings) and cargo xtask policy. One victory-gpu run in four failed main's own multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately. That test also flakes on main alone, so it isn't from this batch.
  • Not checked: no game run (the maintainer asked us to work on GitHub only).

Thanks @AnastasisKon!

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6094926140 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/498#pullrequestreview-6094926140). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T01:36:42Z. **Review:** APPROVED --- Check report (helping the maintainer clear the queue): - **CI:** `check` and `macos-scripts` green on the current head. - **Read:** the whole diff (tests only, in the existing `#[cfg(test)]` module). Every GFX10 opcode table is sorted and resolves to its own names. No translator code changes. - **Local check:** current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#397 #399 #422 #467 #471 #475 #479 #481 #486 #489 #494 #498 #505 #511). On it, the `victory-gpu` (arm64), `victory-shader`, `victory-backend`, `victory-metal` and `victory` tests pass, as do the macOS script tests (`rustup-path.sh`, `run-summary-compare.sh`, `run-summary.sh --self-test`), Windows clippy (`-D warnings`) and `cargo xtask policy`. One `victory-gpu` run in four failed main's own `multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately`. That test also flakes on main alone, so it isn't from this batch. - **Not checked:** no game run (the maintainer asked us to work on GitHub only). Thanks @AnastasisKon!
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!498
No description provided.