Shaders: pixel barycentrics through SV_Barycentrics and live interpolation values (reopens #453, #1738) #3588

Open
github-bot wants to merge 12 commits from github-bot/gh-3588 into main AGit
Owner

@⁠zed6000 on GitHub · 2026-11-27 19:24 UTC · original
zed6000:revive-barycentrics → main · +1462 −192 · 7 files · 12 commits · open

This reopens #1738 by @⁠jaschinski97-ops (live interpolation values), which includes the pixel-barycentrics work of #453 by @⁠AntoninMichelq that it builds on. Both were closed on 2026-11-26 without being merged. The change is still needed on main: one pixel program the title runs in the intro is refused with emit: barycentrics read directly.

The branch is #1738's last head (9d59892) merged onto main 63bcca4. The merge is clean, and all original commits and authors are kept.

Measured on an RX 7900 XTX (driver 32.0.32029.2010), Windows 11:

  • Shader census of the shipped shaders.rpf (translate --validate --list, 26,084 programs), compared with main 63bcca4 program by program: +1, 0 lost. The one is that "barycentrics read directly" refusal.
  • cargo test -p victory-shader --lib --locked: 325 passed, 0 failed.
  • In the game, as part of the tested set in #3347, the intro runs with 0 dropped draws and faces drawn.

Merge notes for the open shader PRs touching the same code (#1924, #2978, #385, #2999) are in my comment on #1738.

I'm happy to hand this back if any of the original authors wants to continue it. AI-assisted (Claude Code); counts only, no game data.

**@⁠zed6000** on GitHub · 2026-11-27 19:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/3588) `zed6000:revive-barycentrics` → `main` · +1462 −192 · 7 files · 12 commits · open This reopens #1738 by @⁠jaschinski97-ops (live interpolation values), which includes the pixel-barycentrics work of #453 by @⁠AntoninMichelq that it builds on. Both were closed on 2026-11-26 without being merged. The change is still needed on `main`: one pixel program the title runs in the intro is refused with `emit: barycentrics read directly`. The branch is #1738's last head (`9d59892`) merged onto `main` `63bcca4`. The merge is clean, and all original commits and authors are kept. **Measured** on an RX 7900 XTX (driver 32.0.32029.2010), Windows 11: - **Shader census** of the shipped `shaders.rpf` (`translate --validate --list`, 26,084 programs), compared with `main` `63bcca4` program by program: **+1, 0 lost**. The one is that "barycentrics read directly" refusal. - `cargo test -p victory-shader --lib --locked`: 325 passed, 0 failed. - In the game, as part of the tested set in #3347, the intro runs with 0 dropped draws and faces drawn. Merge notes for the open shader PRs touching the same code (#1924, #2978, #385, #2999) are in my comment on #1738. I'm happy to hand this back if any of the original authors wants to continue it. AI-assisted (Claude Code); counts only, no game data.
Pixel programs that use the I/J VGPRs as plain values (custom
interpolation, math on the weights) failed with "barycentrics read
directly". They are now channels y and z of an SV_Barycentrics input
(SM 6.1+, the emitter targets 6.6) declared with the interpolation mode
of their kind (perspective/linear, center/centroid/sample), one element
per mode (semantic index 0 and 1), with the Barycentrics shader flag and
SFI0 feature. GFX10 interpolates P0 + i (P1 - P0) + j (P2 - P0) with P0
the provoking vertex, which the host's barycentrics weight as vertex 0,
so i = y and j = z.

The VGPRs are loaded on first use as a value, so programs that only feed
them to v_interp_* declare nothing new. A console signature's own
SV_Barycentrics row (D3D name 23) is parsed and reused. Pull-model
barycentrics stay unsupported.

SV_Barycentrics is left unpacked (no row, packing location -1), like
other non-packed system values: the DXIL validator refuses it in a row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
v_interp_p1/p2 (and the f16 forms) fed with an i or j that is not the
loaded input VGPR now evaluate each half as the hardware does: P0 + i
(P1 - P0) for the first, the old dst + j (P2 - P0) for the second, with
the vertex values read by attributeAtVertex. That needs the element
declared constant, so every other interpolation of the same attribute
row is weighed from its vertices with SV_Barycentrics of its mode, and
flat reads stay loadInput of the provoking vertex. v_interp_mov of P10
and P20 reads P1 - P0 and P2 - P0 the same way when the program also
interpolates the attribute (so the hardware holds the deltas); alone it
is still refused.

The translate command's tally counts Interp::Weighted as interpolated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
lower.rs: keep the PR's lazy barycentric VGPR inputs next to main's
`Reg::S(n)` arm for uninitialized SGPRs. mod.rs: the barycentric test
helper passes the structure to resource::track, which now takes it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
DXIL allows at most two SV_Barycentrics input elements, one perspective
and one linear. A program reading both perspective center and centroid
I/J as values declared two perspective elements, which the validator
refuses ("There can only be up to two input attributes of
SV_Barycentrics with different perspective interpolation mode").

The second mode of the same kind is now an Unsupported reason rather
than a second element. Reusing the first element would hand centroid
reads center weights (or the reverse), which differ on edge pixels: a
silent wrong value. Before this PR such reads were refused anyway.

Test: center + centroid values are refused; centroid alone still
translates with one element.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:29:14 +00:00
The merged #453 and #1738 changes took emit/lower.rs to 533,630 bytes, over the
asset policy's 524,288-byte limit. Their methods (lazy_barycentric, barycentric,
interp, per_vertex, interpolated, eval_channel, vertex_input) and the two mode
helpers move unchanged to emit/lower/interp.rs, as the permlane code did in
#3587. lower.rs is 518,013 bytes now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 21:04 UTC · original

Verified on AMD Radeon 780M (RDNA3, Ryzen 7 8845HS), Windows 11, head 6f32448.

  • barycentric filter: 24/24 passed, 5 of 5 runs.
  • Added the pixel-level draw test from #3553's review (barycentric_draw_tests.rs, branch kilolimaVI/VIctory tests/barycentric-draw) on top of this PR. It draws a triangle and checks every pixel against the expected attribute values:
case 780M WARP
x and y interpolated 95 px, 0 wrong 95 px, 0 wrong
I and J as values 95 px, 0 wrong 95 px, 0 wrong
x with a computed I 95 px, 0 wrong 95 px, 0 wrong
x interpolated, P0 of y (NEW-120) 95 px, 0 wrong 95 px, 0 wrong
x interpolated, P10 of x 95 px, 0 wrong 95 px, 0 wrong
P0 of x and y alone 95 px, 0 wrong 95 px, 0 wrong
  • Full suite (victory-shader + victory-gpu --features diagnostics): 575 passed, 0 failed.

This matches #3553's result on the same test, so the two PRs render identically here; the choice between them can be made on the code alone.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 21:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/3588#issuecomment-7228111700) Verified on AMD Radeon 780M (RDNA3, Ryzen 7 8845HS), Windows 11, head 6f32448. - `barycentric` filter: 24/24 passed, 5 of 5 runs. - Added the pixel-level draw test from #3553's review (`barycentric_draw_tests.rs`, branch kilolimaVI/VIctory `tests/barycentric-draw`) on top of this PR. It draws a triangle and checks every pixel against the expected attribute values: | case | 780M | WARP | |---|---|---| | x and y interpolated | 95 px, 0 wrong | 95 px, 0 wrong | | I and J as values | 95 px, 0 wrong | 95 px, 0 wrong | | x with a computed I | 95 px, 0 wrong | 95 px, 0 wrong | | x interpolated, P0 of y (NEW-120) | 95 px, 0 wrong | 95 px, 0 wrong | | x interpolated, P10 of x | 95 px, 0 wrong | 95 px, 0 wrong | | P0 of x and y alone | 95 px, 0 wrong | 95 px, 0 wrong | - Full suite (`victory-shader` + `victory-gpu --features diagnostics`): 575 passed, 0 failed. This matches #3553's result on the same test, so the two PRs render identically here; the choice between them can be made on the code alone. AI-assisted (Claude).
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/3588/head:github-bot/gh-3588'
git switch 'github-bot/gh-3588'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3588'
git switch 'github-bot/gh-3588'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3588'
git switch 'github-bot/gh-3588'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3588'
git switch 'main'
git merge --squash 'github-bot/gh-3588'
git switch 'main'
git merge --ff-only 'github-bot/gh-3588'
git switch 'main'
git merge 'github-bot/gh-3588'
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!3588
No description provided.