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

Manually merged
github merged 1 commit from github-bot/gh-498 into gh-pr/498/base 2026-11-28 01:42:43 +00:00 AGit
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 22:18 UTC · original
AnastasisKon:vibe/opcode-name-tests-1705ac → main · +91 −0 · 1 files · 1 commits · merged 2026-11-28 01:36 UTC

What this changes

Refs #481. 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
**@⁠AnastasisKon** on GitHub · 2026-11-27 22:18 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/498) `AnastasisKon:vibe/opcode-name-tests-1705ac` → `main` · +91 −0 · 1 files · 1 commits · merged 2026-11-28 01:36 UTC ## What this changes Refs #481. 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
Refs #477. Every encoding's table entry resolves to its own name through
name() (a table edit can no longer silently rename an instruction), tables
are sorted for the binary search, opcodes past a table's end resolve to no
name, EXP names itself whatever its opcode field holds, and the VOP3
encoding resolves VOPC/VOP2/VOP1 at their fixed bases (0x000-0x0ff,
0x100-0x13f, 0x180-0x1ff) with the VOP3 table between (0x140 =
v_fma_legacy_f32, #321). Synthetic opcodes only; no behaviour change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 22:22:55 +00:00
Author
Owner

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

Two pull requests pin #481 — this one and #484 (vibe/opcode-name-tests-4f9c68, opened 19 minutes earlier). Both are test-only and green. I have closed #484 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 #484 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 #484 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 #484 loses nothing.

**@⁠AnastasisKon** on GitHub · 2026-11-27 22:19 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/498#issuecomment-7229222726) Two pull requests pin #481 — this one and #484 (`vibe/opcode-name-tests-4f9c68`, opened 19 minutes earlier). Both are test-only and green. I have closed #484 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 #484 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 #484 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 #484 loses nothing.
github-bot changed target branch from main to gh-pr/498/base 2026-11-28 01:42:42 +00:00
github manually merged commit 5e665274d9 into gh-pr/498/base 2026-11-28 01:42:43 +00:00
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 01:36 UTC · original · approved these changes

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 (#401 #403 #426 #471 #475 #479 #483 #485 #490 #493 #498 #502 #509 #515). 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!

**@⁠Olima34** on GitHub · 2026-11-28 01:36 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/498#pullrequestreview-6094926140) · **approved these changes** 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 (#401 #403 #426 #471 #475 #479 #483 #485 #490 #493 #498 #502 #509 #515). 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.