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

Open
artor410 wants to merge 5 commits from upstream-pr/3553 into main
artor410 commented 2026-11-27 17:19:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by artor410 on 2026-11-27T17:19:19Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5530554761 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3553). Originally posted by [artor410](https://github.com/artor410) on 2026-11-27T17:19:19Z. --- 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)
kilolimaVI commented 2026-11-27 17:45:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T17:45:25Z.

Review: COMMENTED


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

<!-- greyfinch-sync:Marvisak/VIctory:review:6091701284 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3553#pullrequestreview-6091701284). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T17:45:25Z. **Review:** COMMENTED --- 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 commented 2026-11-27 18:57:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T18:57:16Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7226039943 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3553#issuecomment-7226039943). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T18:57:16Z. --- 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).
andrewpozdnakov7-jpg commented 2026-11-27 19:08:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T19:08:59Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7226238646 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3553#issuecomment-7226238646). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T19:08:59Z. --- 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 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/3553:upstream-pr/3553'
git switch 'upstream-pr/3553'

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/3553'
git switch 'upstream-pr/3553'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3553'
git switch 'upstream-pr/3553'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3553'
git switch 'main'
git merge --squash 'upstream-pr/3553'
git switch 'main'
git merge --ff-only 'upstream-pr/3553'
git switch 'main'
git merge 'upstream-pr/3553'
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!3553
No description provided.