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

Open
opened 2026-11-27 21:58:18 +00:00 by AnastasisKon · 5 comments
AnastasisKon commented 2026-11-27 21:58:18 +00:00 (Migrated from github.com)
Contributor

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


What

crates/victory-shader/src/gfx10 resolves an encoding plus an opcode word to an instruction name. apps/victory's survey counts opcodes it cannot name (shader.rs), and refusal messages and corpus comparisons read the same names — yet nothing tests the resolution, so a table edit can silently rename an instruction.

What this 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 its 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.

Test-only: synthetic instruction words and opcodes, no game data, no behaviour change, no new dependencies.

How it was tested

  • cargo test -p victory-shader (new unit tests)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy
  • Shader corpus sweep: not applicable, no translation changes.
  • Game run: not needed.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6655104031 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/477). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T21:58:18Z. --- ## What `crates/victory-shader/src/gfx10` resolves an encoding plus an opcode word to an instruction name. `apps/victory`'s survey counts opcodes it cannot name (`shader.rs`), and refusal messages and corpus comparisons read the same names — yet nothing tests the resolution, so a table edit can silently rename an instruction. ## What this 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 its 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. Test-only: synthetic instruction words and opcodes, no game data, no behaviour change, no new dependencies. ## How it was tested - `cargo test -p victory-shader` (new unit tests) - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo xtask policy` - Shader corpus sweep: not applicable, no translation changes. - Game run: not needed.
AnastasisKon commented 2026-11-27 21:58:27 +00:00 (Migrated from github.com)
Author
Contributor

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


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7228916548 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/477#issuecomment-7228916548). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T21:58:27Z. --- /claim
AnastasisKon commented 2026-11-27 22:15:54 +00:00 (Migrated from github.com)
Author
Contributor

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


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229173938 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/477#issuecomment-7229173938). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T22:15:54Z. --- /claim
github-actions[bot] commented 2026-11-27 22:16:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T22:16:04Z.


Claimed by @AnastasisKon. Open a draft pull request with Refs #477 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229176616 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/477#issuecomment-7229176616). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T22:16:04Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #477` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-28 12:44:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:44:32Z.


/release - done without a PR: on branch vibe/opcode-name-tests-1705ac, in my fork's main. Opcode-name resolution is pinned by every_table_entry_resolves_to_its_own_name, tables_are_sorted_so_the_binary_search_finds_them, vop3_carries_vopc_vop2_and_vop1_at_their_bases_and_its_own_table_between and an_opcode_past_the_end_of_a_table_has_no_name.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239434911 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/477#issuecomment-7239434911). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:44:32Z. --- /release - done without a PR: on branch `vibe/opcode-name-tests-1705ac`, in my fork's `main`. Opcode-name resolution is pinned by `every_table_entry_resolves_to_its_own_name`, `tables_are_sorted_so_the_binary_search_finds_them`, `vop3_carries_vopc_vop2_and_vop1_at_their_bases_and_its_own_table_between` and `an_opcode_past_the_end_of_a_table_has_no_name`.
github-actions[bot] commented 2026-11-28 12:44:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T12:44:40Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239436555 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/477#issuecomment-7239436555). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T12:44:40Z. --- Released. This issue is free to claim.
Sign in to join this conversation.
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#477
No description provided.