Shaders: a first interpolation half read early is the interpolation #2355

Closed
github-bot wants to merge 1 commit from gh-pr/2355/head into gh-pr/2355/base
Owner

@⁠Calvix2k on GitHub · 2026-11-25 11:34 UTC · original
Calvix2k:codex/shader-interp-first-half → main · +46 −1 · 2 files · 1 commits · closed without merging

Two pixel shaders of this title are dropped with a reason that names the place exactly:

victory_gpu::pipeline: shader does not translate; its pipelines' draws are dropped
  stage="pixel" hash=78f3f2fc53a69531
  error=converter shader.dxil v1: GFX10 code at 0x1464: the first half of an interpolation is not supported

(and 38bf0814e721a1b3 at the same offset.)

An interpolation is two instructions on the console: v_interp_p1_f32 makes the half attr * i, v_interp_p2_f32 completes it. The host has only the whole, so io::raise records the interpolation at the completing half and lists the first halves it completes in Interp::first. A shader that reads a half's dword before its completing half finds no interpolation at that site and the whole program is refused.

What this does

Lower gains a second map, firsts, from each v_interp_p1_f32 site to the interpolation that completes it, and interp() falls back to it. A first half is lowered as the interpolation itself: the completing half recomputes and stores the same value, so a title that stores the half early sees the finished value instead of the program being dropped.

Scope

Only the 32-bit v_interp_p1_f32. v_interp_p1ll_f16 packs two 16-bit halves into one dword, and a read of the whole dword is not an interpolation — a_half_over_a_first_interpolation_half_reads_as_a_half still refuses those, and stays green.

Verification

  • New a_first_half_read_early_is_the_interpolation: a pixel shader that moves a first half's dword out (as these two do) and completes the interpolation afterwards now emits and validates.
  • cargo test -p victory-shader --lib: 248 passed, 0 failed, 3 ignored (Windows 10 19045 / RX 7800 XT, SM 6.6 through the Agility runtime for the test binaries); clippy -D warnings clean.
  • Not yet confirmed on the title: I stopped the game runs to work the backlog, so the check that 78f3f2fc and 38bf0814 now translate is pending — I will report it here as soon as a run is back.
**@⁠Calvix2k** on GitHub · 2026-11-25 11:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2355) `Calvix2k:codex/shader-interp-first-half` → `main` · +46 −1 · 2 files · 1 commits · closed without merging Two pixel shaders of this title are dropped with a reason that names the place exactly: ``` victory_gpu::pipeline: shader does not translate; its pipelines' draws are dropped stage="pixel" hash=78f3f2fc53a69531 error=converter shader.dxil v1: GFX10 code at 0x1464: the first half of an interpolation is not supported ``` (and `38bf0814e721a1b3` at the same offset.) An interpolation is two instructions on the console: `v_interp_p1_f32` makes the half `attr * i`, `v_interp_p2_f32` completes it. The host has only the whole, so `io::raise` records the interpolation at the completing half and lists the first halves it completes in `Interp::first`. A shader that reads a half's dword *before* its completing half finds no interpolation at that site and the whole program is refused. ### What this does `Lower` gains a second map, `firsts`, from each `v_interp_p1_f32` site to the interpolation that completes it, and `interp()` falls back to it. A first half is lowered as the interpolation itself: the completing half recomputes and stores the same value, so a title that stores the half early sees the finished value instead of the program being dropped. ### Scope Only the 32-bit `v_interp_p1_f32`. `v_interp_p1ll_f16` packs two 16-bit halves into one dword, and a read of the whole dword is not an interpolation — `a_half_over_a_first_interpolation_half_reads_as_a_half` still refuses those, and stays green. ### Verification - New `a_first_half_read_early_is_the_interpolation`: a pixel shader that moves a first half's dword out (as these two do) and completes the interpolation afterwards now emits and validates. - `cargo test -p victory-shader --lib`: **248 passed, 0 failed, 3 ignored** (Windows 10 19045 / RX 7800 XT, SM 6.6 through the Agility runtime for the test binaries); clippy `-D warnings` clean. - Not yet confirmed on the title: I stopped the game runs to work the backlog, so the check that `78f3f2fc` and `38bf0814` now translate is pending — I will report it here as soon as a run is back.
The two halves of an interpolation are separate instructions, and the
lowering only knows the whole: it makes the value at the completing
`v_interp_p2_f32` and records the `v_interp_p1_f32` sites that half
completes (`Interp::first`). A shader that reads a half's dword *before* its
completing half — two pixel shaders in this title store one — finds no
interpolation at that site and was dropped with "the first half of an
interpolation".

Map those sites to the interpolation that completes them (a second map
built from `Interp::first`) and lower them as that interpolation. The
completing `p2` recomputes the same value, so a title that reads the half
early sees the finished value instead of nothing, and a shader that today
cannot be translated at all now can.

The 16-bit form stays refused: `v_interp_p1ll_f16` packs two halves in one
dword, and a read of the whole dword is not an interpolation. Its test
(`a_half_over_a_first_interpolation_half_reads_as_a_half`) still holds.

`a_first_half_read_early_is_the_interpolation` covers the new shape; the
lib suite is 248 passed, 0 failed, 3 ignored on Windows 10 / RX 7800 XT
with the Agility runtime for the test binaries, clippy `-D warnings` clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:03:13 +00:00
github-bot closed this pull request 2026-11-26 05:03:13 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:33 UTC · original

Automated triage for the maintainers.

Needs work (evidence). The change makes the shader translate, but the value it gives an early-read first half is not the console's. On GFX10, v_interp_p1_f32 writes P0 + P10·i and v_interp_p2_f32 adds P20·j; with the firsts fallback in Lower::interp (crates/victory-shader/src/emit/lower.rs) the first half is lowered as the whole interpolation. In the new test a_first_half_read_early_is_the_interpolation, v4 (moved out after p1) therefore exports P0 + P10·i + P20·j where the console exports P0 + P10·i; the test only checks that the shader emits and validates, not the exported value. Please show what the two title shaders (78f3f2fc53a69531, 38bf0814e721a1b3) do with the half around 0x1464, e.g. whether the moved dword is itself completed by a later p2 and only stored after that; if so, io::raise should follow the move so the completing half is found, rather than lowering every first half as the whole value. What would change the verdict: that disassembly context (described, not dumped) and a test that checks exported values. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2355#issuecomment-7167037951) <!-- victory-triage v1 head=124d7614246fb12b3af9061e7f974ed7a4f23c94 verdict=needs-work at=2026-11-25T15:40:00Z --> Automated triage for the maintainers. **Needs work (evidence).** The change makes the shader translate, but the value it gives an early-read first half is not the console's. On GFX10, `v_interp_p1_f32` writes `P0 + P10·i` and `v_interp_p2_f32` adds `P20·j`; with the `firsts` fallback in `Lower::interp` (`crates/victory-shader/src/emit/lower.rs`) the first half is lowered as the whole interpolation. In the new test `a_first_half_read_early_is_the_interpolation`, `v4` (moved out after `p1`) therefore exports `P0 + P10·i + P20·j` where the console exports `P0 + P10·i`; the test only checks that the shader emits and validates, not the exported value. Please show what the two title shaders (`78f3f2fc53a69531`, `38bf0814e721a1b3`) do with the half around 0x1464, e.g. whether the moved dword is itself completed by a later `p2` and only stored after that; if so, `io::raise` should follow the move so the completing half is found, rather than lowering every first half as the whole value. What would change the verdict: that disassembly context (described, not dumped) and a test that checks exported values. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 16:27 UTC · original

I disassembled both programs the review names, from translate --list on the title's shaders.rpf (26,517 containers): PS_DeferredTextured_c5fd36bb_Wrapped (#38bf0814e721a1b3, @0x7be5e42) and PS_DeferredTextured_9e3a1555_Wrapped (#78f3f2fc53a69531, @0x7c2af0b), via shader-info --disasm on the pack. What is at 0x1464 in both:

00145c: v_cvt_pkrtz_f16_f32 v2, v12, v23
001460: v_cvt_pkrtz_f16_f32 v3, v13, v24
001464: exp mrt1, v2, v2, v3, v3 compr

So the export reads two packed dwords built from v12/v23 and v13/v24. I then checked every half:

  • Both programs have 15 v_interp_p1* and 15 v_interp_p2*. Each p2's accumulator (its destination for _f32, src[2] for _f16) is last written by its own p1 at the same register (v14, v6, v7, v12, v25, v26, v15, v35, v23, v34, v31, v29, v30, v0, and the seven f16 halves).
  • The moves of first-half results are after the completing p2: v_mov_b32 v12, v14 at 0x860 (after p2 v14 at 0x274, which is itself rewritten at 0x2c8), v_mov_b32 v40, v25 at 0x534, v_mov_b32 v39, v26 at 0x538, v_mov_b32 v21, v25 at 0x111c. None of them is used as the accumulator of a later p2.

So the "moved dword completed later" pattern is not what these two programs do: by register, there is no early-read first half here. The reason at the export is a value the lowering had already marked Missing("the first half of an interpolation"), i.e. a v_interp_p2 site that io::raise did not record in interps (or a phi path through one), reaching v12/v23 through the arithmetic chain. That needs the site named — the same treatment as #2365 — rather than a fallback at the read.

That is also why I agree with the verdict: the firsts fallback would export P0 + P10*i + P20*j where the console exports P0 + P10*i, so it should not land on this evidence. I am closing this PR rather than keeping a known-wrong value; the next step is a change in io::raise that reports the p2 site it could not pair, which I can make once the diagnostic names it. The test and the two programs are in the thread for whoever picks it up.

**@⁠Calvix2k** on GitHub · 2026-11-25 16:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2355#issuecomment-7168018709) I disassembled both programs the review names, from `translate --list` on the title's `shaders.rpf` (26,517 containers): `PS_DeferredTextured_c5fd36bb_Wrapped` (`#38bf0814e721a1b3`, `@0x7be5e42`) and `PS_DeferredTextured_9e3a1555_Wrapped` (`#78f3f2fc53a69531`, `@0x7c2af0b`), via `shader-info --disasm` on the pack. What is at `0x1464` in both: ``` 00145c: v_cvt_pkrtz_f16_f32 v2, v12, v23 001460: v_cvt_pkrtz_f16_f32 v3, v13, v24 001464: exp mrt1, v2, v2, v3, v3 compr ``` So the export reads two packed dwords built from v12/v23 and v13/v24. I then checked every half: - Both programs have 15 `v_interp_p1*` and 15 `v_interp_p2*`. Each p2's accumulator (its destination for `_f32`, `src[2]` for `_f16`) is last written by its own p1 at the same register (v14, v6, v7, v12, v25, v26, v15, v35, v23, v34, v31, v29, v30, v0, and the seven f16 halves). - The moves of first-half results are *after* the completing p2: `v_mov_b32 v12, v14` at `0x860` (after p2 v14 at `0x274`, which is itself rewritten at `0x2c8`), `v_mov_b32 v40, v25` at `0x534`, `v_mov_b32 v39, v26` at `0x538`, `v_mov_b32 v21, v25` at `0x111c`. None of them is used as the accumulator of a later p2. So the "moved dword completed later" pattern is not what these two programs do: by register, there is no early-read first half here. The reason at the export is a value the lowering had already marked `Missing("the first half of an interpolation")`, i.e. a `v_interp_p2` site that `io::raise` did not record in `interps` (or a phi path through one), reaching `v12`/`v23` through the arithmetic chain. That needs the site named — the same treatment as #2365 — rather than a fallback at the read. That is also why I agree with the verdict: the `firsts` fallback would export `P0 + P10*i + P20*j` where the console exports `P0 + P10*i`, so it should not land on this evidence. I am closing this PR rather than keeping a known-wrong value; the next step is a change in `io::raise` that reports the p2 site it could not pair, which I can make once the diagnostic names it. The test and the two programs are in the thread for whoever picks it up.

Pull request closed

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!2355
No description provided.