Shaders: VOP3 f16 interpolation attr63.w is not a 32-bit literal #2515

Open
github-bot wants to merge 5 commits from github-bot/gh-2515 into main AGit
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-25 15:09 UTC · original
mgunes1311-lab:shader-vop3-interp-attr63-w → main · +201 −4 · 3 files · 5 commits · open

Summary

  • In RDNA2 VOP3 16-bit interpolation instructions (v_interp_p1ll_f16, v_interp_p1lv_f16, v_interp_p2_f16), the 9-bit src0 field (w1 & 0x1FF) encodes high << 8 | attr_chan << 6 | attr rather than a register or literal operand (as fields.rs already decodes via Operand::Attr).
  • When an instruction interpolates attr63.w (low half: attr = 63, chan = 3, high = false), w1 & 0x1FF equals 0xFF, causing gfx10::instruction to treat the 2-dword instruction as a 3-dword literal instruction and consume the following instruction word.
  • Check only src1 and src2 (w1 >> 9 and w1 >> 18) for 0xFF on VOP3 v_interp_* opcodes while preserving literal detection on src1 and src2.

Testing

  • gfx10::tests::vop3_f16_interp_attr63_w_is_not_a_literal: verifies 2-dword decoding on v_interp_p1ll_f16, v_interp_p1lv_f16, and v_interp_p2_f16 with attr63.w and 3-dword decoding when src1 or src2 is 0xFF.
  • gfx10::sp3::tests::interp_f16_attr63_w_disassembles_without_literal: verifies SP3 disassembly for attr63.w (low and high halves) and literal operands.
  • emit::synthetic_tests::f16_interpolation_of_attr63_w_draws_on_gpu: translates a pixel shader interpolating attr63.w, validates the emitted DXIL container, and verifies interpolated output pixels on both hardware D3D12 and WARP.
**@⁠mgunes1311-lab** on GitHub · 2026-11-25 15:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2515) `mgunes1311-lab:shader-vop3-interp-attr63-w` → `main` · +201 −4 · 3 files · 5 commits · open ## Summary - In RDNA2 VOP3 16-bit interpolation instructions (`v_interp_p1ll_f16`, `v_interp_p1lv_f16`, `v_interp_p2_f16`), the 9-bit `src0` field (`w1 & 0x1FF`) encodes `high << 8 | attr_chan << 6 | attr` rather than a register or literal operand (as `fields.rs` already decodes via `Operand::Attr`). - When an instruction interpolates `attr63.w` (low half: `attr = 63`, `chan = 3`, `high = false`), `w1 & 0x1FF` equals `0xFF`, causing `gfx10::instruction` to treat the 2-dword instruction as a 3-dword literal instruction and consume the following instruction word. - Check only `src1` and `src2` (`w1 >> 9` and `w1 >> 18`) for `0xFF` on VOP3 `v_interp_*` opcodes while preserving literal detection on `src1` and `src2`. ## Testing - `gfx10::tests::vop3_f16_interp_attr63_w_is_not_a_literal`: verifies 2-dword decoding on `v_interp_p1ll_f16`, `v_interp_p1lv_f16`, and `v_interp_p2_f16` with `attr63.w` and 3-dword decoding when `src1` or `src2` is `0xFF`. - `gfx10::sp3::tests::interp_f16_attr63_w_disassembles_without_literal`: verifies SP3 disassembly for `attr63.w` (low and high halves) and literal operands. - `emit::synthetic_tests::f16_interpolation_of_attr63_w_draws_on_gpu`: translates a pixel shader interpolating `attr63.w`, validates the emitted DXIL container, and verifies interpolated output pixels on both hardware D3D12 and WARP.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:08:00 +00:00
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 15:21 UTC · original

Hardware run of the three new tests on NVIDIA Ampere: RTX 3050 Laptop, driver 610.62, Windows 11 26200, D3D12 debug layer enabled for the test host (local patch in emit/host.rs; Host::new fails without it).

cargo test --locked -p victory-shader --features host --lib attr63 -- --test-threads=1

tree vop3_f16_interp_attr63_w_is_not_a_literal interp_f16_attr63_w_disassembles_without_literal f16_interpolation_of_attr63_w_draws_on_gpu
this PR d45c849 pass pass pass: drew on the RTX 3050 and on WARP (I added a print after Host::new so a skipped device would show)
main 940d32f + only the two test commits (ebd17a5, d45c849) (not present: lives in the fix commit) fails: Isa { offset: 12, reason: "instruction runs past the end of the code" } fails before drawing: Unsupported { offset: 20, what: "the first half of an interpolation" }

So on main the 0xFF in src0 makes the decoder eat the next dword as a literal, and the translation is refused rather than drawn wrong. With the fix both instructions decode as two dwords and the interpolated value matches on hardware.

AI-assisted; synthetic tests only.

**@⁠Dathinel** on GitHub · 2026-11-25 15:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2515#issuecomment-7166725947) Hardware run of the three new tests on NVIDIA Ampere: RTX 3050 Laptop, driver 610.62, Windows 11 26200, D3D12 debug layer enabled for the test host (local patch in `emit/host.rs`; `Host::new` fails without it). `cargo test --locked -p victory-shader --features host --lib attr63 -- --test-threads=1` | tree | `vop3_f16_interp_attr63_w_is_not_a_literal` | `interp_f16_attr63_w_disassembles_without_literal` | `f16_interpolation_of_attr63_w_draws_on_gpu` | |---|---|---|---| | this PR `d45c849` | pass | pass | pass: drew on the RTX 3050 **and** on WARP (I added a print after `Host::new` so a skipped device would show) | | `main` `940d32f` + only the two test commits (`ebd17a5`, `d45c849`) | (not present: lives in the fix commit) | fails: `Isa { offset: 12, reason: "instruction runs past the end of the code" }` | fails before drawing: `Unsupported { offset: 20, what: "the first half of an interpolation" }` | So on main the `0xFF` in `src0` makes the decoder eat the next dword as a literal, and the translation is refused rather than drawn wrong. With the fix both instructions decode as two dwords and the interpolated value matches on hardware. AI-assisted; synthetic tests only.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 15:26 UTC · original

Verification (Windows 11, WARP/CPU only) — head d45c8498c361fed763f85fe0512b75bb4830c26c

Tested: the PR head, which is origin/main 940d32f plus the PR commits (merge-base is 940d32f, so it merges cleanly and is a fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, dxil.dll from Windows SDK 10.0.26100. No physical GPU involved: VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 set so every Host::new takes the WARP adapter.

command result
cargo test -p victory-shader --locked --features host --lib attr63 -- --test-threads=1 3 passed, 0 failed, 0 ignored
same 3 tests with the decoder fix disabled (attr = false && ..., tests kept) 3 failed: Isa { offset: 12, reason: "instruction runs past the end of the code" } (decoder, sp3) and Unsupported { offset: 20, what: "the first half of an interpolation" } (draw test)
cargo test -p victory-shader --locked --lib -- --test-threads=1 (also with --features host) 248 passed, 2 failed, 3 ignored
cargo clippy -p victory-shader --all-targets --locked -- -D warnings (also with --features host) clean
cargo xtask policy asset policy: 182 files ok

The 2 failures are a WARP baseline, not this PR: emit::synthetic_tests::gathers_at_a_level_match_the_hardware and permutes_read_the_lane_named_and_zero_from_lanes_left_out are hardware-behaviour checks that fail the same way on origin/main 940d32f under forced WARP (245 passed, 2 failed, 3 ignored there; +3 passed = this PR's new tests).

Diff read: vop3(w1, attr) skips only src0 for v_interp_* opcodes (gated on the opcode name), src1/src2 still take 0xFF as a literal, and the tests cover both sides (src0 0xFF no literal; src1/src2 0xFF literal). The draw test renders the expected interpolated values on WARP. No findings. Not exercised: real GPU (WARP only; see the existing RTX 3050 comment).

AI use: Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 15:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2515#issuecomment-7166839948) **Verification (Windows 11, WARP/CPU only) — head `d45c8498c361fed763f85fe0512b75bb4830c26c`** Tested: the PR head, which is `origin/main` `940d32f` plus the PR commits (merge-base is `940d32f`, so it merges cleanly and is a fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, `dxil.dll` from Windows SDK 10.0.26100. No physical GPU involved: `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` set so every `Host::new` takes the WARP adapter. | command | result | |---|---| | `cargo test -p victory-shader --locked --features host --lib attr63 -- --test-threads=1` | 3 passed, 0 failed, 0 ignored | | same 3 tests with the decoder fix disabled (`attr = false && ...`, tests kept) | 3 failed: `Isa { offset: 12, reason: "instruction runs past the end of the code" }` (decoder, sp3) and `Unsupported { offset: 20, what: "the first half of an interpolation" }` (draw test) | | `cargo test -p victory-shader --locked --lib -- --test-threads=1` (also with `--features host`) | 248 passed, 2 failed, 3 ignored | | `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (also with `--features host`) | clean | | `cargo xtask policy` | `asset policy: 182 files ok` | The 2 failures are a WARP baseline, not this PR: `emit::synthetic_tests::gathers_at_a_level_match_the_hardware` and `permutes_read_the_lane_named_and_zero_from_lanes_left_out` are hardware-behaviour checks that fail the same way on `origin/main` `940d32f` under forced WARP (245 passed, 2 failed, 3 ignored there; +3 passed = this PR's new tests). Diff read: `vop3(w1, attr)` skips only src0 for `v_interp_*` opcodes (gated on the opcode name), src1/src2 still take `0xFF` as a literal, and the tests cover both sides (src0 `0xFF` no literal; src1/src2 `0xFF` literal). The draw test renders the expected interpolated values on WARP. No findings. Not exercised: real GPU (WARP only; see the existing RTX 3050 comment). AI use: Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:31 UTC · original · edited 2026-11-25 22:16 UTC

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/synthetic_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 18:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2515#issuecomment-7171027060) · edited 2026-11-25 22:16 UTC <!-- victory-triage v1 head=d45c8498c361fed763f85fe0512b75bb4830c26c verdict=needs-rebase at=2026-11-25T22:19:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/synthetic_tests.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
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/2515/head:github-bot/gh-2515'
git switch 'github-bot/gh-2515'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2515'
git switch 'github-bot/gh-2515'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2515'
git switch 'github-bot/gh-2515'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2515'
git switch 'main'
git merge --squash 'github-bot/gh-2515'
git switch 'main'
git merge --ff-only 'github-bot/gh-2515'
git switch 'main'
git merge 'github-bot/gh-2515'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2515
No description provided.