Shaders: P0 beside an interpolation of the same row (NEW-120, stacked on #3335) #3553

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

@⁠artor410 on GitHub · 2026-11-27 17:19 UTC · original
artor410:new-120-p0-beside-interp → main · +1223 −476 · 7 files · 5 commits · open

NEW-120 (#1633). Stacked on #3335: only the last commit (1101cd9) is new here.

A pixel program that reads P0 (v_interp_mov_f32 p0) of an attribute row and also interpolates that row is refused with one input interpolated two ways, on main and on #3335: P0 wants a constant element, the interpolation a perspective one. #3335's per_vertex already handles P10/P20 of an interpolated row this way but skips P0.

Fix: per_vertex also counts P0 of a row the program interpolates. The element becomes constant, P0 is its provoking vertex (flat load), and the interpolation weighs the vertices with SV_Barycentrics, the same path P10/P20 use. P0 alone keeps the plain flat read and declares no barycentrics.

This is the case #1738 fixed before it was closed; #3335 doesn't carry it.

Tests (synthetic only, no title data)

  • p0_beside_an_interpolation_of_the_row: P0 before or after the p1/p2 pair, on the same channel or another. Each case translates, sets the Barycentrics feature, declares one SV_Barycentrics, makes TEXCOORD0 constant, and passes the DXIL validator. It fails on #3335 without this commit.
  • p0_alone_declares_no_barycentrics: no regression for P0 on its own.

cargo test -p victory-shader --lib on RTX 3070 Ti (Windows 11): 310 passed, 3 failed. The 3 failures are the ones main already has on this card (stride_tests ×2, gathers_at_a_level_match_the_hardware). I skipped heap_direct_texture_reads_mark_their_heap_index because it crashes the process on NVIDIA (FIND-36). cargo clippy -p victory-shader --all-targets -D warnings is clean.

Not run: a render readback of the new case.

🤖 Generated with Claude Code

**@⁠artor410** on GitHub · 2026-11-27 17:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/3553) `artor410:new-120-p0-beside-interp` → `main` · +1223 −476 · 7 files · 5 commits · open NEW-120 (#1633). Stacked on #3335: only the last commit (`1101cd9`) is new here. A pixel program that reads P0 (`v_interp_mov_f32 p0`) of an attribute row and also interpolates that row is refused with `one input interpolated two ways`, on `main` and on #3335: P0 wants a constant element, the interpolation a perspective one. #3335's `per_vertex` already handles P10/P20 of an interpolated row this way but skips P0. Fix: `per_vertex` also counts P0 of a row the program interpolates. The element becomes constant, P0 is its provoking vertex (flat load), and the interpolation weighs the vertices with `SV_Barycentrics`, the same path P10/P20 use. P0 alone keeps the plain flat read and declares no barycentrics. This is the case #1738 fixed before it was closed; #3335 doesn't carry it. ### Tests (synthetic only, no title data) - `p0_beside_an_interpolation_of_the_row`: P0 before or after the p1/p2 pair, on the same channel or another. Each case translates, sets the Barycentrics feature, declares one `SV_Barycentrics`, makes TEXCOORD0 constant, and passes the DXIL validator. It fails on #3335 without this commit. - `p0_alone_declares_no_barycentrics`: no regression for P0 on its own. `cargo test -p victory-shader --lib` on RTX 3070 Ti (Windows 11): 310 passed, 3 failed. The 3 failures are the ones `main` already has on this card (`stride_tests` ×2, `gathers_at_a_level_match_the_hardware`). I skipped `heap_direct_texture_reads_mark_their_heap_index` because it crashes the process on NVIDIA (FIND-36). `cargo clippy -p victory-shader --all-targets -D warnings` is clean. Not run: a render readback of the new case. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
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
A pixel program that reads P0 (v_interp_mov_f32 p0) of an attribute row
and also interpolates that row was refused with "one input interpolated
two ways": P0 wanted a constant element, the interpolation a perspective
one. per_vertex now counts P0 of an interpolated row too, so the element
is constant, P0 is its provoking vertex, and the interpolation weighs the
vertices with SV_Barycentrics, as P10/P20 already do. P0 alone keeps the
plain flat read and declares no barycentrics.

Stacked on #3335.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 17:20:45 +00:00
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 17:45 UTC · original · reviewed

Windows run with the DXIL validator present (Windows SDK dxil.dll), head 1101cd9, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1:

  • barycentric_tests: 11 passed, 0 failed, so every new SV_Barycentrics shape (including p0_beside_an_interpolation_of_the_row) validates; Linux CI skips that step.
  • cargo test -p victory-shader on the 780M: 314 passed, 0 failed.

These tests validate but don't draw, so vertex order under GetAttributeAtVertex on real hardware isn't covered by them; I can add an AMD draw test for P0/P10/P20 against an interpolated row if that's useful.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 17:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/3553#pullrequestreview-6091701284) · **reviewed** Windows run with the DXIL validator present (Windows SDK `dxil.dll`), head 1101cd9, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1: - `barycentric_tests`: 11 passed, 0 failed, so every new SV_Barycentrics shape (including `p0_beside_an_interpolation_of_the_row`) validates; Linux CI skips that step. - `cargo test -p victory-shader` on the 780M: 314 passed, 0 failed. These tests validate but don't draw, so vertex order under `GetAttributeAtVertex` on real hardware isn't covered by them; I can add an AMD draw test for P0/P10/P20 against an interpolated row if that's useful. AI-assisted (Claude).
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 18:57 UTC · original

Follow-up with a draw test, as offered above: https://github.com/kilolimaVI/VIctory/commits/tests/barycentric-draw (one commit on top of 1101cd9, a new file emit/barycentric_draw_tests.rs).

It draws a triangle in general position whose three vertices carry distinct TEXCOORD0 values, through six pixel programs, and compares every covered pixel with the weights at its centre: x and y interpolated; I and J read as values; x with a computed I; x interpolated beside P0 of y (NEW-120); P10 beside it; P0 alone. So SV_Barycentrics and attributeAtVertex must keep the console's vertex order (P0 the provoking vertex, I and J the weights of vertices 1 and 2).

Radeon 780M (RDNA3) and WARP: 95 pixels per case, 0 wrong in all twelve, with the DXIL validator on. Feel free to cherry-pick it into this PR.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 18:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/3553#issuecomment-7226039943) Follow-up with a draw test, as offered above: https://github.com/kilolimaVI/VIctory/commits/tests/barycentric-draw (one commit on top of 1101cd9, a new file `emit/barycentric_draw_tests.rs`). It draws a triangle in general position whose three vertices carry distinct TEXCOORD0 values, through six pixel programs, and compares every covered pixel with the weights at its centre: x and y interpolated; I and J read as values; x with a computed I; x interpolated beside P0 of y (NEW-120); P10 beside it; P0 alone. So `SV_Barycentrics` and `attributeAtVertex` must keep the console's vertex order (P0 the provoking vertex, I and J the weights of vertices 1 and 2). Radeon 780M (RDNA3) and WARP: 95 pixels per case, 0 wrong in all twelve, with the DXIL validator on. Feel free to cherry-pick it into this PR. AI-assisted (Claude).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 19:08 UTC · original

I ran @⁠kilolimaVI's synthetic draw test on Windows WARP 1.0.22 with Agility SDK 1.620.2 and DXIL validation required. All six draws read back 95 covered pixels each with zero mismatches. That includes ordinary interpolation, the I/J values, computed I, P0 on a row also being interpolated, P10 on that row, and P0 alone. The 11 existing barycentric lowering tests passed too.

With VICTORY_WARP=1, the offered fixture printed the same WARP device under both adapter labels. Test branch preserves @⁠kilolimaVI's exact 7eff061 on this PR's 1101cd9, then adds 0f3d463 to run WARP once and to check the adapter's SV_Barycentrics support before drawing. The six readbacks above were repeated on that tip. Strict shader Clippy passed for default and all features, and the asset policy check passed.

@⁠artor410 can bring both test commits into #3553 if useful. Please retain the respective Git authors on cherry-pick or rebase. If you fold my follow-up into another commit, please include Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 19:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3553#issuecomment-7226238646) I ran @⁠kilolimaVI's synthetic draw test on Windows WARP 1.0.22 with Agility SDK 1.620.2 and DXIL validation required. All six draws read back 95 covered pixels each with zero mismatches. That includes ordinary interpolation, the I/J values, computed I, P0 on a row also being interpolated, P10 on that row, and P0 alone. The 11 existing barycentric lowering tests passed too. With `VICTORY_WARP=1`, the offered fixture printed the same WARP device under both adapter labels. [Test branch](https://github.com/andrewpozdnakov7-jpg/VIctory/commits/codex2/pr3553-barycentric-draw) preserves @⁠kilolimaVI's exact `7eff061` on this PR's `1101cd9`, then adds `0f3d463` to run WARP once and to check the adapter's `SV_Barycentrics` support before drawing. The six readbacks above were repeated on that tip. Strict shader Clippy passed for default and all features, and the asset policy check passed. @⁠artor410 can bring both test commits into #3553 if useful. Please retain the respective Git authors on cherry-pick or rebase. If you fold my follow-up into another commit, please include `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
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/3553/head:github-bot/gh-3553'
git switch 'github-bot/gh-3553'

Merge

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