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

Open
zed6000 wants to merge 12 commits from upstream-pr/3588 into main
zed6000 commented 2026-11-27 19:24:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-27T19:24:08Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5531997767 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3588). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-27T19:24:08Z. --- 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.
kilolimaVI commented 2026-11-27 21:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T21:04:42Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7228111700 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3588#issuecomment-7228111700). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T21:04:42Z. --- 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).
michi-feny commented 2026-11-28 18:22:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by michi-feny on 2026-11-28T18:22:37Z.


This covers hosts that have SV_Barycentrics. Hosts that do not have it end up on
"emit: barycentrics read directly" and lose the input: my RX 5700 XT reports
OPTIONS3::BarycentricsSupported=false and MeshShaderTier=0, and so does an RX 580.

There is a second route that needs no system value at all, and it works together with this PR
rather than against it — SV_Barycentrics where the host has it, the emulation where it does not:

  1. A small geometry stage in front of the pixel stage writes one one-hot weight per triangle
    corner, (1,0,0) / (0,1,0) / (0,0,1).
  2. The interpolant is noperspective: barycentrics are affine in screen space, so it is exact.
  3. The pixel stage reads that interpolant (VICTORYBARY) in place of the barycentric system value.
  4. The feature flag and the read have to be changed together. Guarding only the flag and leaving
    the read behind produces DXIL that the AMD compiler crashes on (amdxc64, first-chance
    0xc0000005).

Measured on that card: refusals of the barycentric kind 249 -> 0, pipelines built during loading
11 -> 49, and a pixel program that previously did not translate now does.

The code, GPL-3.0-or-later, two commits on branch barycentric-emu:
github.com/michi-feny/cool_fox@01a77ea (shader)
github.com/michi-feny/cool_fox@319eb4a (gpu)

Four sites: lower.rs fn barycentric, lower.rs fn vertex_input, rect.rs/mod.rs (barycentric_gs,
VICTORYBARY), pipeline/host.rs (the OPTIONS3 probe). AI-assisted (Claude); counts only, no game
data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7243743244 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3588#issuecomment-7243743244). Originally posted by [michi-feny](https://github.com/michi-feny) on 2026-11-28T18:22:37Z. --- This covers hosts that have SV_Barycentrics. Hosts that do not have it end up on "emit: barycentrics read directly" and lose the input: my RX 5700 XT reports OPTIONS3::BarycentricsSupported=false and MeshShaderTier=0, and so does an RX 580. There is a second route that needs no system value at all, and it works together with this PR rather than against it — SV_Barycentrics where the host has it, the emulation where it does not: 1. A small geometry stage in front of the pixel stage writes one one-hot weight per triangle corner, (1,0,0) / (0,1,0) / (0,0,1). 2. The interpolant is noperspective: barycentrics are affine in screen space, so it is exact. 3. The pixel stage reads that interpolant (VICTORYBARY) in place of the barycentric system value. 4. The feature flag and the read have to be changed together. Guarding only the flag and leaving the read behind produces DXIL that the AMD compiler crashes on (amdxc64, first-chance 0xc0000005). Measured on that card: refusals of the barycentric kind 249 -> 0, pipelines built during loading 11 -> 49, and a pixel program that previously did not translate now does. The code, GPL-3.0-or-later, two commits on branch barycentric-emu: https://github.com/michi-feny/cool_fox/commit/01a77ea (shader) https://github.com/michi-feny/cool_fox/commit/319eb4a (gpu) Four sites: lower.rs fn barycentric, lower.rs fn vertex_input, rect.rs/mod.rs (barycentric_gs, VICTORYBARY), pipeline/host.rs (the OPTIONS3 probe). AI-assisted (Claude); counts only, no game data.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3588:upstream-pr/3588'
git switch 'upstream-pr/3588'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3588'
git switch 'upstream-pr/3588'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3588'
git switch 'upstream-pr/3588'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3588'
git switch 'main'
git merge --squash 'upstream-pr/3588'
git switch 'main'
git merge --ff-only 'upstream-pr/3588'
git switch 'main'
git merge 'upstream-pr/3588'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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
Marvisak/VIctory!3588
No description provided.