Shaders: decode the VOP3 interpolation forms (attr63.w is no literal) #70

Open
github-bot wants to merge 2 commits from github-bot/gh-70 into main AGit
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 21:34 UTC · original
lcg007xd-c:fix/vop3-interp-decode → main · +83 −2 · 5 files · 2 commits · open

What

The VOP3 interpolation instructions put an attribute and its channel in the first source field, not an operand code. That covers v_interp_p1ll_f16, v_interp_p1lv_f16, v_interp_p2_f16, and the 64-bit encodings of v_interp_p1/p2/mov_f32. attr63.w encodes as 0xFF, and the decoder's length rule read that as "a 32-bit literal follows". The instruction then swallowed the next dword, and everything after it decoded out of step. llvm-mc reads all of them as two dwords. For these opcodes, the first source no longer counts toward a literal.

VOP3 0x200–0x202 also get their names: v_interp_p1_f32, v_interp_p2_f32 and v_interp_mov_f32, LLVM's _e64 forms. Before, they decoded with no name. Each takes two sources, and v_interp_mov_f32's parameter prints as p10/p20/p0, as in VINTRP. The input pass only understands the VINTRP pair, so translation refuses these VOP3 forms with an error instead of misreading them. A test pins that.

Upstream has an open PR for the same length bug (Marvisak/VIctory#2515). This is an independent fix on VItoriaBr's decoder.

Tests

  • vop3_interpolation_attributes_are_not_literals checks six encodings from llvm-mc -triple=amdgcn -mcpu=gfx1030: the three f32 _e64 forms with attr31.w, and the three f16 forms with attr63.w. Each must decode as one two-dword instruction with LLVM's operands (without the _e64 suffix). With the length change reverted, the test fails.
  • vop3_encoded_f32_interpolation_is_refused checks that a VOP3-encoded p1/p2 pair decodes with its names and that io::raise refuses it.
  • The portable CI commands and Windows-target clippy (--target x86_64-pc-windows-msvc) pass locally.

Not tested: Windows runtime, GPU, and the game. Real shaders have fewer than 33 attributes, so attr63.w should not appear in practice. The length bug matters for disassembly and for decoding data or garbage as code.

Note: the Windows check job fails on current main for an unrelated reason (5668b8b, missing Layout::bytes_from), which #64 fixes.

🤖 Generated with Claude Code

**@⁠lcg007xd-c** on GitHub · 2026-11-25 21:34 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/70) `lcg007xd-c:fix/vop3-interp-decode` → `main` · +83 −2 · 5 files · 2 commits · open ## What The VOP3 interpolation instructions put an attribute and its channel in the first source field, not an operand code. That covers `v_interp_p1ll_f16`, `v_interp_p1lv_f16`, `v_interp_p2_f16`, and the 64-bit encodings of `v_interp_p1/p2/mov_f32`. `attr63.w` encodes as `0xFF`, and the decoder's length rule read that as "a 32-bit literal follows". The instruction then swallowed the next dword, and everything after it decoded out of step. `llvm-mc` reads all of them as two dwords. For these opcodes, the first source no longer counts toward a literal. VOP3 0x200–0x202 also get their names: `v_interp_p1_f32`, `v_interp_p2_f32` and `v_interp_mov_f32`, LLVM's `_e64` forms. Before, they decoded with no name. Each takes two sources, and `v_interp_mov_f32`'s parameter prints as `p10`/`p20`/`p0`, as in VINTRP. The input pass only understands the VINTRP pair, so translation refuses these VOP3 forms with an error instead of misreading them. A test pins that. Upstream has an open PR for the same length bug (Marvisak/VIctory#2515). This is an independent fix on VItoriaBr's decoder. ## Tests - `vop3_interpolation_attributes_are_not_literals` checks six encodings from `llvm-mc -triple=amdgcn -mcpu=gfx1030`: the three f32 `_e64` forms with `attr31.w`, and the three f16 forms with `attr63.w`. Each must decode as one two-dword instruction with LLVM's operands (without the `_e64` suffix). With the length change reverted, the test fails. - `vop3_encoded_f32_interpolation_is_refused` checks that a VOP3-encoded p1/p2 pair decodes with its names and that `io::raise` refuses it. - The portable CI commands and Windows-target clippy (`--target x86_64-pc-windows-msvc`) pass locally. Not tested: Windows runtime, GPU, and the game. Real shaders have fewer than 33 attributes, so `attr63.w` should not appear in practice. The length bug matters for disassembly and for decoding data or garbage as code. Note: the Windows `check` job fails on current main for an unrelated reason (5668b8b, missing `Layout::bytes_from`), which #64 fixes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The VOP3 interpolation instructions (v_interp_p1ll/p1lv/p2_f16, and the
64-bit encodings of v_interp_p1/p2/mov_f32) take an attribute and its
channel in the first source field. attr63.w encodes as 0xFF, which the
length rule read as "a 32-bit literal follows", so the instruction
swallowed the next dword and the rest of the program decoded out of
step. llvm-mc reads each of them as two dwords; the first source of
these opcodes no longer counts toward a literal.

VOP3 0x200-0x202 get their names (v_interp_p1_f32, v_interp_p2_f32,
v_interp_mov_f32, as LLVM's _e64 forms), two sources each, and
v_interp_mov_f32's parameter prints as p10/p20/p0 as in VINTRP. The
input pass understands only the VINTRP pair, so the VOP3 f32 forms are
refused, and a test checks that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:43:02 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/70/head:github-bot/gh-70'
git switch 'github-bot/gh-70'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-70'
git switch 'github-bot/gh-70'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-70'
git switch 'github-bot/gh-70'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-70'
git switch 'main'
git merge --squash 'github-bot/gh-70'
git switch 'main'
git merge --ff-only 'github-bot/gh-70'
git switch 'main'
git merge 'github-bot/gh-70'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.