Shaders: pixel barycentrics through SV_Barycentrics (rebased #453) #3335

Open
kotekompotek wants to merge 4 commits from upstream-pr/3335 into main
kotekompotek commented 2026-11-26 18:54:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T18:54:35Z.


Revival of #453 (itself grown from #442), rebased onto current main. Both earlier PRs closed unmerged — #442 yielded to the broader #453, and #453 hit needs-rebase with no one picking it up. Original authorship is preserved in the commits; the design is theirs, the rebase and one integration fix are mine.

What

A pixel program receives its barycentric pairs (i, j) in input VGPRs as SPI_PS_INPUT_ADDR enables them. When it uses them only in v_interp_*, that already translates. When it reads them as data — arithmetic, an export, a join — lowering stopped with barycentrics read directly (one program in the retail pack: PS_SampleFromHigherResGrid). Such reads are now channels of SV_Barycentrics (SM 6.1):

  • i is SV_Barycentrics.y, j is .z; the element is rowless and unpacked, declared only when a barycentric is actually read as data — programs that only interpolate keep their signatures and need no new device feature.
  • Perspective center/centroid/sample map to DXIL interpolation modes 2/3/6, the linear pairs to the noperspective forms 4/5/7 — one shared mode table for v_interp and the direct reads.
  • D3D allows one perspective-correct and one noperspective element; a program reading two same-family pairs as data is refused by name.
  • Computed barycentrics: a v_interp_p1/p2 whose i/j are not the loaded inputs evaluates P0 + i(P1-P0) + j(P2-P0) from the vertex values through attributeAtVertex (opcode 137), with the element forced to constant interpolation.
  • System value 23 parses/serializes as internal kind 28; shader flag bit 22 and the SFI0 feature bit are set.

What the rebase changed beyond conflict resolution

Main's counted-v_movreld proof (#457) recognized raw barycentric inputs because they were unrepresentable (Val::Missing). With direct barycentrics representable, the proof now recognizes raw barycentric input values directly; malformed/partial counted fills keep the input value instead of failing. indexed_move_initializes_an_input_before_its_first_use was updated to the new correct behavior: complete fills declare no SV_Barycentrics, partial fills preserve the input and do.

Verification

  • cargo test -p victory-shader --lib: 224 passed / 88 failed — the 88 are byte-identical to the origin/main baseline on the same machine (GTX 1050, SM 6.5 ceiling; most want SM 6.6). The 10 new tests all pass.
  • cargo clippy -p victory-shader --all-targets: clean.
  • Prior art on the original head: iGoldenNinja's full validation on #453 — 168/168 emitted, validated, pipelines created (RTX 5080). Worth re-measuring on this rebase.

Test plan

  • emit::barycentric_tests — 9 tests: direct reads, two-element split, same-family refusal, no-declaration for pure interpolation, computed weights, constant weights
  • io::tests::computed_barycentrics_evaluate_each_half
  • validator-backed indexed-move cases
  • hardware validation on SM 6.6 host (beyond this machine)

Generated with Devin

<!-- greyfinch-sync:Marvisak/VIctory:issue:5515594570 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T18:54:35Z. --- Revival of #453 (itself grown from #442), rebased onto current main. Both earlier PRs closed unmerged — #442 yielded to the broader #453, and #453 hit needs-rebase with no one picking it up. Original authorship is preserved in the commits; the design is theirs, the rebase and one integration fix are mine. ## What A pixel program receives its barycentric pairs (i, j) in input VGPRs as `SPI_PS_INPUT_ADDR` enables them. When it uses them only in `v_interp_*`, that already translates. When it reads them as data — arithmetic, an export, a join — lowering stopped with `barycentrics read directly` (one program in the retail pack: `PS_SampleFromHigherResGrid`). Such reads are now channels of `SV_Barycentrics` (SM 6.1): - i is `SV_Barycentrics.y`, j is `.z`; the element is rowless and unpacked, declared only when a barycentric is actually read as data — programs that only interpolate keep their signatures and need no new device feature. - Perspective center/centroid/sample map to DXIL interpolation modes 2/3/6, the linear pairs to the `noperspective` forms 4/5/7 — one shared mode table for `v_interp` and the direct reads. - D3D allows one perspective-correct and one `noperspective` element; a program reading two same-family pairs as data is refused by name. - Computed barycentrics: a `v_interp_p1/p2` whose i/j are not the loaded inputs evaluates `P0 + i(P1-P0) + j(P2-P0)` from the vertex values through `attributeAtVertex` (opcode 137), with the element forced to constant interpolation. - System value 23 parses/serializes as internal kind 28; shader flag bit 22 and the SFI0 feature bit are set. ## What the rebase changed beyond conflict resolution Main's counted-`v_movreld` proof (#457) recognized raw barycentric inputs because they were unrepresentable (`Val::Missing`). With direct barycentrics representable, the proof now recognizes raw barycentric input values directly; malformed/partial counted fills keep the input value instead of failing. `indexed_move_initializes_an_input_before_its_first_use` was updated to the new correct behavior: complete fills declare no `SV_Barycentrics`, partial fills preserve the input and do. ## Verification - `cargo test -p victory-shader --lib`: 224 passed / 88 failed — the 88 are byte-identical to the `origin/main` baseline on the same machine (GTX 1050, SM 6.5 ceiling; most want SM 6.6). The 10 new tests all pass. - `cargo clippy -p victory-shader --all-targets`: clean. - Prior art on the original head: iGoldenNinja's full validation on #453 — 168/168 emitted, validated, pipelines created (RTX 5080). Worth re-measuring on this rebase. #### Test plan - [x] `emit::barycentric_tests` — 9 tests: direct reads, two-element split, same-family refusal, no-declaration for pure interpolation, computed weights, constant weights - [x] `io::tests::computed_barycentrics_evaluate_each_half` - [x] validator-backed indexed-move cases - [ ] hardware validation on SM 6.6 host (beyond this machine) Generated with [Devin](https://devin.ai)
Dukestar69 commented 2026-11-26 19:09:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T19:09:57Z.

Review: COMMENTED


Tested on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

Tests and clippy pass cleanly:

  • cargo test -p victory-shader --lib io:: -- --test-threads=1: 5 passed, 0 failed.
  • cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1: 17 passed, 0 failed.
  • cargo clippy -p victory-shader -p victory --all-targets -- -D warnings: clean.

However, cargo xtask policy fails because crates/victory-shader/src/emit/lower.rs grows to 534,321 bytes, exceeding the 524,288-byte (512 KiB) file-size limit by 10,033 bytes:

POLICY: crates/victory-shader/src/emit/lower.rs: 534321 bytes exceeds the 524288-byte limit
Error: 1 asset-policy violation(s). Nothing from the game may be committed; see docs/asset-policy.md

Moving the new barycentrics lowering code into a submodule under crates/victory-shader/src/emit/lower/ will bring lower.rs back under the limit.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6079344678 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#pullrequestreview-6079344678). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T19:09:57Z. **Review:** COMMENTED --- Tested on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). Tests and clippy pass cleanly: - `cargo test -p victory-shader --lib io:: -- --test-threads=1`: 5 passed, 0 failed. - `cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1`: 17 passed, 0 failed. - `cargo clippy -p victory-shader -p victory --all-targets -- -D warnings`: clean. However, `cargo xtask policy` fails because `crates/victory-shader/src/emit/lower.rs` grows to `534,321` bytes, exceeding the `524,288`-byte (512 KiB) file-size limit by `10,033` bytes: ``` POLICY: crates/victory-shader/src/emit/lower.rs: 534321 bytes exceeds the 524288-byte limit Error: 1 asset-policy violation(s). Nothing from the game may be committed; see docs/asset-policy.md ``` Moving the new barycentrics lowering code into a submodule under `crates/victory-shader/src/emit/lower/` will bring `lower.rs` back under the limit. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
oni-swr commented 2026-11-26 19:16:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T19:16:40Z.


WARP/CPU verification of head 8965f49f (claim: #1633)

Environment: Windows 11, WARP only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), dxil.dll from Windows SDK 10.0.26100.0 (VICTORY_DXIL), no physical GPU, no game files. -j 4, --locked, separate target dir. Control: origin/main @ 63bcca43. Merge: git merge-tree against current origin/main is clean (head is 1 commit ahead, 0 behind).

Check main 63bcca43 PR 8965f49f
cargo test -p victory-shader --lib -- --test-threads=1 298 passed, 4 failed, 3 ignored 308 passed, 4 failed, 3 ignored (+10)
cargo test -p victory translate pass pass
cargo clippy -p victory-shader -p victory --all-targets -- -D warnings clean clean
xtask policy 191 files ok FAIL
  • The 4 failures are identical on main and on the PR, so they are not caused by this PR: synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out}. They compare lane results against the host on WARP.
  • The 10 new tests pass: 9 in emit::barycentric_tests and io::tests::computed_barycentrics_evaluate_each_half. They are not present on main.
  • CI check failure reproduced exactly. cargo run -p xtask -- policy (and xtask policy::tests::repository_passes_policy in CI) reports: POLICY: crates/victory-shader/src/emit/lower.rs: 534321 bytes exceeds the 524288-byte limit. Every other test in the CI log passed. On main the file is under the limit. The PR adds about 469 lines to lower.rs. It needs to move code out of that file or be split (for example into a new module) to get under 512 KiB. It is a size-policy failure, not a behavioural one.

AI disclosure: run by Claude Code (Claude Sonnet 5.5), coordinated by Antigravity.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7201399757 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#issuecomment-7201399757). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T19:16:40Z. --- **WARP/CPU verification of head `8965f49f`** (claim: #1633) Environment: Windows 11, **WARP only** (`VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`), `dxil.dll` from Windows SDK 10.0.26100.0 (`VICTORY_DXIL`), no physical GPU, no game files. `-j 4`, `--locked`, separate target dir. Control: `origin/main` @ `63bcca43`. Merge: `git merge-tree` against current `origin/main` is clean (head is 1 commit ahead, 0 behind). | Check | main `63bcca43` | PR `8965f49f` | |---|---|---| | `cargo test -p victory-shader --lib -- --test-threads=1` | 298 passed, 4 failed, 3 ignored | 308 passed, 4 failed, 3 ignored (+10) | | `cargo test -p victory translate` | pass | pass | | `cargo clippy -p victory-shader -p victory --all-targets -- -D warnings` | clean | clean | | `xtask policy` | 191 files ok | **FAIL** | - The 4 failures are identical on main and on the PR, so they are not caused by this PR: `synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out}`. They compare lane results against the host on WARP. - The 10 new tests pass: 9 in `emit::barycentric_tests` and `io::tests::computed_barycentrics_evaluate_each_half`. They are not present on main. - **CI `check` failure reproduced exactly.** `cargo run -p xtask -- policy` (and `xtask policy::tests::repository_passes_policy` in CI) reports: `POLICY: crates/victory-shader/src/emit/lower.rs: 534321 bytes exceeds the 524288-byte limit`. Every other test in the CI log passed. On main the file is under the limit. The PR adds about 469 lines to `lower.rs`. It needs to move code out of that file or be split (for example into a new module) to get under 512 KiB. It is a size-policy failure, not a behavioural one. AI disclosure: run by Claude Code (Claude Sonnet 5.5), coordinated by Antigravity.
andrewpozdnakov7-jpg commented 2026-11-26 19:33:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T19:33:25Z.


The failed CI job reports one repository-policy failure on 8965f49: lower.rs is 534,321 bytes, above the 524,288-byte limit. e276f31 moves the pixel interpolation code into lower/interpolation.rs. The moved bodies match the original byte for byte, apart from the visibility of the three module entry points. The resulting files are 514,086 and 20,734 bytes.

The failing repository_passes_policy test and cargo xtask policy both pass (192 files). The CLI translation tests and strict all-target Clippy for victory-shader and victory passed, including the all-features configuration. The barycentric and indexed-move tests also passed. On app-local Agility 1.620.2 / WARP 1.0.22, a separate 16×16 draw with generated vertices returned 256/256 exact pixels for direct barycentric reads and 256/256 for vertex interpolation with a modified weight.

kotekompotek, please consider applying the module split and rerunning CI. If you fold it into another commit, please preserve its Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7201718035 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#issuecomment-7201718035). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T19:33:25Z. --- The failed CI job reports one repository-policy failure on `8965f49`: `lower.rs` is 534,321 bytes, above the 524,288-byte limit. [`e276f31`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/e276f319d3cb32866448529b16910deda2a749f3) moves the pixel interpolation code into `lower/interpolation.rs`. The moved bodies match the original byte for byte, apart from the visibility of the three module entry points. The resulting files are 514,086 and 20,734 bytes. The failing `repository_passes_policy` test and `cargo xtask policy` both pass (192 files). The CLI translation tests and strict all-target Clippy for `victory-shader` and `victory` passed, including the all-features configuration. The barycentric and indexed-move tests also passed. On app-local Agility 1.620.2 / WARP 1.0.22, a separate 16×16 draw with generated vertices returned 256/256 exact pixels for direct barycentric reads and 256/256 for vertex interpolation with a modified weight. kotekompotek, please consider applying the module split and rerunning CI. If you fold it into another commit, please preserve its Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
kotekompotek commented 2026-11-26 19:51:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T19:51:49Z.


Full-pack validation on the retail shaders.rpf (v1.0.2.1, 26 084 programs), dxil.dll from SDK 10.0.26100.0:

main this PR
vertex+pixel emitted 14 246 / 14 247 14 247 / 14 247
vertex+pixel validated — 14 247 / 14 247
barycentrics read directly refusals 1 0

PS_SampleFromHigherResGrid now emits and validates — no out of bound coord or any other validator complaint in the whole vertex+pixel set. Compute/mesh validation numbers are unchanged from main (this branch is PS-only). Note the run was made on this branch alone, so the unrelated 195-program FIND-26 bucket (#3222) still shows in the resources line; the two branches are independent.

Side discovery from the same run, not caused by this PR: 748 emitted compute programs fail validation with 'incompatible with the shader stage' and 71 mesh with 'vertex plus primitive output size is greater than 32768' — pre-existing on main, worth its own census entry.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7202039202 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#issuecomment-7202039202). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T19:51:49Z. --- Full-pack validation on the retail shaders.rpf (v1.0.2.1, 26 084 programs), dxil.dll from SDK 10.0.26100.0: | | main | this PR | |---|---|---| | vertex+pixel emitted | 14 246 / 14 247 | **14 247 / 14 247** | | vertex+pixel validated | — | **14 247 / 14 247** | | `barycentrics read directly` refusals | 1 | **0** | `PS_SampleFromHigherResGrid` now emits *and validates* — no `out of bound coord` or any other validator complaint in the whole vertex+pixel set. Compute/mesh validation numbers are unchanged from main (this branch is PS-only). Note the run was made on this branch alone, so the unrelated 195-program FIND-26 bucket (#3222) still shows in the resources line; the two branches are independent. Side discovery from the same run, not caused by this PR: 748 emitted compute programs fail validation with 'incompatible with the shader stage' and 71 mesh with 'vertex plus primitive output size is greater than 32768' — pre-existing on main, worth its own census entry.
fuzeofficlal commented 2026-11-26 20:02:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:02:04Z.

Review: CHANGES_REQUESTED


The split into crates/victory-shader/src/emit/lower/barycentric.rs cleanly brings emit/lower.rs back under the size limit (504,649 bytes), and the DXIL SV_Barycentrics constants/modes (SFI0 1 << 17, flags 1 << 22, semantic kind 28 -> 23, (1 - i - j, i, j) triangle weights) and tests (emit::barycentric_tests 9/9, emit::tests 17/17 with dxil.dll, io:: 5/5, emit::lower 33/33, apps/victory 18/18, clippy, xtask policy) all pass locally at e495d2dd.

However, there are a few issues at e495d2dd that need to be addressed before merge:

  1. Corrupted UTF-8 comments in crates/victory-shader/src/emit/lower.rs (starting at line 366):

    • The rebase/split rewrote non-ASCII symbols (×, π, →, ², −, ±, ≤) in unrelated lower.rs doc comments as mojibake (Г—, ПЂ, в†’, ВІ, в€’, В±, ≤) across 14+ lines. Please restore the original UTF-8 text.
  2. P1 — Dead per-vertex reads can leave flags::BARYCENTRICS set without any usage (barycentric.rs:602, bitcode.rs:513-515, shader.rs:578-586):

    • vertex_input sets self.s.flags |= flags::BARYCENTRICS when emitting a ReadNone dx.op.attributeAtVertex call (137). If the interpolated output is never exported/consumed, bitcode::Module::write drops dead ReadNone calls (rooted() returns false), while Shader::finish never recomputes flags::BARYCENTRICS from self.m.uses(). DXC validation rejects a module whose SFI0/entry flags advertise barycentrics with neither an SV_Barycentrics input nor a live attributeAtVertex call ("Flags must match usage").
  3. P1 — Imported SV_Barycentrics signature elements can emit invalid DXIL signatures (mod.rs:455, 627, barycentric.rs:230-266):

    • signature() + emit() initialize imported SV_Barycentrics rows with row: Some(register) and interp: 2. If an imported element goes unread, it stays packed (row.is_some()) without setting flags::BARYCENTRICS. Additionally, if SV_Barycentrics1 is already declared and another interpolation family is added, barycentric.rs:238 sets index = count() as u32 (1), producing a duplicate SV_Barycentrics1 element.

Non-blocking notes:

  • P2 (FP16 coefficient precision): barycentric.rs:425, 575 computes vk - v0 in f32 for computed-weight FP16 interpolations instead of narrowing P10/P20 coefficients to f16 as RDNA2 v_interp_p1ll_f16/v_interp_p2_f16 do.
  • P3 (v_interp_mov_f32): barycentric.rs:365 should mask VSRC with & 3 per RDNA2 ISA (VSRC[1:0]).
  • Diagnostic count (apps/victory/src/translate.rs:709-710): counting each Interp::Weighted site increments t.interpolated twice for a split first/second half pair.
  • Formatting: rustfmt --edition 2024 --check passes on translate.rs and io.rs, with 5 small line-wrap diffs in crates/victory-shader/src/emit/lower/barycentric.rs (366, 374, 383, 467, 652).
<!-- greyfinch-sync:Marvisak/VIctory:review:6079912245 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#pullrequestreview-6079912245). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T20:02:04Z. **Review:** CHANGES_REQUESTED --- The split into `crates/victory-shader/src/emit/lower/barycentric.rs` cleanly brings `emit/lower.rs` back under the size limit (`504,649` bytes), and the DXIL `SV_Barycentrics` constants/modes (`SFI0` `1 << 17`, flags `1 << 22`, semantic kind `28 -> 23`, `(1 - i - j, i, j)` triangle weights) and tests (`emit::barycentric_tests` 9/9, `emit::tests` 17/17 with `dxil.dll`, `io::` 5/5, `emit::lower` 33/33, `apps/victory` 18/18, `clippy`, `xtask policy`) all pass locally at `e495d2dd`. However, there are a few issues at `e495d2dd` that need to be addressed before merge: 1. **Corrupted UTF-8 comments in `crates/victory-shader/src/emit/lower.rs` (starting at line `366`)**: - The rebase/split rewrote non-ASCII symbols (`×`, `π`, `→`, `²`, `−`, `±`, `≤`) in unrelated `lower.rs` doc comments as mojibake (`Г—`, `ПЂ`, `в†’`, `ВІ`, `в€’`, `В±`, `≤`) across 14+ lines. Please restore the original UTF-8 text. 2. **P1 — Dead per-vertex reads can leave `flags::BARYCENTRICS` set without any usage (`barycentric.rs:602`, `bitcode.rs:513-515`, `shader.rs:578-586`)**: - `vertex_input` sets `self.s.flags |= flags::BARYCENTRICS` when emitting a `ReadNone` `dx.op.attributeAtVertex` call (`137`). If the interpolated output is never exported/consumed, `bitcode::Module::write` drops dead `ReadNone` calls (`rooted()` returns `false`), while `Shader::finish` never recomputes `flags::BARYCENTRICS` from `self.m.uses()`. DXC validation rejects a module whose `SFI0`/entry flags advertise barycentrics with neither an `SV_Barycentrics` input nor a live `attributeAtVertex` call (`"Flags must match usage"`). 3. **P1 — Imported `SV_Barycentrics` signature elements can emit invalid DXIL signatures (`mod.rs:455, 627`, `barycentric.rs:230-266`)**: - `signature()` + `emit()` initialize imported `SV_Barycentrics` rows with `row: Some(register)` and `interp: 2`. If an imported element goes unread, it stays packed (`row.is_some()`) without setting `flags::BARYCENTRICS`. Additionally, if `SV_Barycentrics1` is already declared and another interpolation family is added, `barycentric.rs:238` sets `index = count() as u32` (`1`), producing a duplicate `SV_Barycentrics1` element. Non-blocking notes: - **P2 (FP16 coefficient precision)**: `barycentric.rs:425, 575` computes `vk - v0` in `f32` for computed-weight FP16 interpolations instead of narrowing `P10`/`P20` coefficients to `f16` as RDNA2 `v_interp_p1ll_f16`/`v_interp_p2_f16` do. - **P3 (`v_interp_mov_f32`)**: `barycentric.rs:365` should mask `VSRC` with `& 3` per RDNA2 ISA (`VSRC[1:0]`). - **Diagnostic count (`apps/victory/src/translate.rs:709-710`)**: counting each `Interp::Weighted` site increments `t.interpolated` twice for a split first/second half pair. - **Formatting**: `rustfmt --edition 2024 --check` passes on `translate.rs` and `io.rs`, with 5 small line-wrap diffs in `crates/victory-shader/src/emit/lower/barycentric.rs` (`366, 374, 383, 467, 652`).
upipibi commented 2026-11-27 00:13:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T00:13:31Z.


Hardware run of head e495d2dd on RTX 3070 (claim: #1633)

Environment: NVIDIA GeForce RTX 3070 8 GB (Ampere, wave32 only), driver 616.56, Windows 11, SM 6.6, Windows SDK 10.0.26100.0 dxil.dll (found automatically by the validator). Head e495d2dd4d60ba7c3c54d7c77258c3f59b86a60d; control origin/main 63bcca43c6a00a758510398fa43096ce7e4f7df0 (the PR's base).

PR's tests, head, 3 runs, cargo test -p victory-shader --lib --features host -- --test-threads=1 --nocapture emit::barycentric_tests computed_barycentrics_evaluate_each_half indexed_move_initializes_an_input_before_its_first_use:

  • run 1: test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 304 filtered out
  • run 2: test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 304 filtered out
  • run 3: test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 304 filtered out

(9 barycentric_tests + io::tests::computed_barycentrics_evaluate_each_half + emit::tests::indexed_move_initializes_an_input_before_its_first_use.) No skip lines. Adapter: these tests translate and run the DXIL validator (dxil.dll, loaded, so the validator ran); they create no D3D12 device, so neither the 3070 nor WARP was used. They do not answer "hardware validation on an SM 6.6 host" for pipeline creation or pixels.

Negative control: the PR's test hunks (emit/mod.rs tests, io.rs tests) applied to 63bcca43 do not compile: error[E0599]: no variant named 'Weighted' found for enum 'io::Interp' at io.rs:754 and io.rs:755.

Full lib, cargo test -p victory-shader --lib --features host -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index (that test aborts with 0xC0000005 on this card on main too, skipped on both trees):

  • head: test result: FAILED. 308 passed; 3 failed; 3 ignored
  • main: test result: FAILED. 298 passed; 3 failed; 3 ignored
  • The same 3 fail on both: emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, emit::synthetic_tests::gathers_at_a_level_match_the_hardware (host-device comparisons on this card, not touched by the PR). +10 passing on head are the new tests.

No game files used.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206280620 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#issuecomment-7206280620). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-27T00:13:31Z. --- **Hardware run of head `e495d2dd` on RTX 3070** (claim: #1633) Environment: NVIDIA GeForce RTX 3070 8 GB (Ampere, wave32 only), driver 616.56, Windows 11, SM 6.6, Windows SDK 10.0.26100.0 `dxil.dll` (found automatically by the validator). Head `e495d2dd4d60ba7c3c54d7c77258c3f59b86a60d`; control `origin/main` `63bcca43c6a00a758510398fa43096ce7e4f7df0` (the PR's base). PR's tests, head, 3 runs, `cargo test -p victory-shader --lib --features host -- --test-threads=1 --nocapture emit::barycentric_tests computed_barycentrics_evaluate_each_half indexed_move_initializes_an_input_before_its_first_use`: - run 1: `test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 304 filtered out` - run 2: `test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 304 filtered out` - run 3: `test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 304 filtered out` (9 `barycentric_tests` + `io::tests::computed_barycentrics_evaluate_each_half` + `emit::tests::indexed_move_initializes_an_input_before_its_first_use`.) No skip lines. Adapter: these tests translate and run the DXIL validator (`dxil.dll`, loaded, so the validator ran); they create no D3D12 device, so neither the 3070 nor WARP was used. They do not answer "hardware validation on an SM 6.6 host" for pipeline creation or pixels. Negative control: the PR's test hunks (`emit/mod.rs` tests, `io.rs` tests) applied to `63bcca43` do not compile: `error[E0599]: no variant named 'Weighted' found for enum 'io::Interp'` at `io.rs:754` and `io.rs:755`. Full lib, `cargo test -p victory-shader --lib --features host -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index` (that test aborts with 0xC0000005 on this card on main too, skipped on both trees): - head: `test result: FAILED. 308 passed; 3 failed; 3 ignored` - main: `test result: FAILED. 298 passed; 3 failed; 3 ignored` - The same 3 fail on both: `emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `emit::synthetic_tests::gathers_at_a_level_match_the_hardware` (host-device comparisons on this card, not touched by the PR). +10 passing on head are the new tests. No game files used. AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
steven-seagull27 commented 2026-11-27 02:35:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-27T02:35:02Z.


I ran a D3D12 raster readback on head e495d2dd. The translated pixel shader and an independent Windows SDK DXC pixel shader returned bit-identical values for all 128 covered RGBA components on each of the RTX 5080, inbox WARP and WARP 1.0.22. Both WARP versions showed a discrepancy with the analytic weights when one shader requested both interpolation modes.

The guest shader exports v0,v1,v2,v3 directly to an RGBA32F target. RG holds perspective-center I/J, BA holds screen-linear-center I/J. Each draw checks all four components in 16 pixels strictly inside the same triangle on an 8×4 target. The threshold is 1e-4. With equal clip w, every program matched at all 16 pixels on every device.

Unequal clip w (1, 2, 4), pixels differing from the analytic weights out of 16

Device Translated dual DXC dual DXC perspective only DXC screen-linear only
NVIDIA GeForce RTX 5080, driver 621.40 0 0 0 0
Microsoft Basic Render Driver, inbox WARP 10.0.26100.10068 16 16 0 0
Microsoft Basic Render Driver, app-local WARP 1.0.22 16 16 0 0

On both WARP runtimes the dual-mode programs missed 32/64 components. All 32 screen-linear components matched. At pixel (2,1) the expected RGBA was (0.2777778, 0.1666667, 0.3125, 0.375). The maximum absolute error across the RTX 5080 draw was about 3e-8. Both WARP versions returned (0.5555556, 0.6666667, 0.3125, 0.375), including when the pixel shader was compiled directly from HLSL. This reproduces the WARP discrepancy independently of the translator. The earlier #442 draw tested perspective and screen-linear weights in separate shaders, which also passed here. Microsoft’s definition of both semantics and vertex ordering

The PR’s original nine translation/validator tests also passed. The same guest export on base 63bcca43 stops before pipeline creation at offset 0x0 with barycentrics read directly is not supported.

The opt-in test and three HLSL references are in this test-only commit. To reproduce from this PR head with Windows SDK DXC installed, run the following.

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/test/pr3335-dual-barycentric-readback
git cherry-pick c0c39ce3246583f784fbc7935bbd3d0df2000c7d
cargo test --locked -p victory-shader --lib raw_center_weights_match_native_rasterization -- --ignored --nocapture --test-threads=1
<!-- greyfinch-sync:Marvisak/VIctory:comment:7208257703 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#issuecomment-7208257703). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-27T02:35:02Z. --- I ran a D3D12 raster readback on head `e495d2dd`. The translated pixel shader and an independent Windows SDK DXC pixel shader returned bit-identical values for all 128 covered RGBA components on each of the RTX 5080, inbox WARP and WARP 1.0.22. Both WARP versions showed a discrepancy with the analytic weights when one shader requested both interpolation modes. The guest shader exports `v0,v1,v2,v3` directly to an RGBA32F target. RG holds perspective-center I/J, BA holds screen-linear-center I/J. Each draw checks all four components in 16 pixels strictly inside the same triangle on an 8×4 target. The threshold is `1e-4`. With equal clip w, every program matched at all 16 pixels on every device. **Unequal clip w (1, 2, 4), pixels differing from the analytic weights out of 16** | Device | Translated dual | DXC dual | DXC perspective only | DXC screen-linear only | |---|---:|---:|---:|---:| | NVIDIA GeForce RTX 5080, driver 621.40 | 0 | 0 | 0 | 0 | | Microsoft Basic Render Driver, inbox WARP 10.0.26100.10068 | 16 | 16 | 0 | 0 | | Microsoft Basic Render Driver, app-local WARP 1.0.22 | 16 | 16 | 0 | 0 | On both WARP runtimes the dual-mode programs missed 32/64 components. All 32 screen-linear components matched. At pixel (2,1) the expected RGBA was `(0.2777778, 0.1666667, 0.3125, 0.375)`. The maximum absolute error across the RTX 5080 draw was about `3e-8`. Both WARP versions returned `(0.5555556, 0.6666667, 0.3125, 0.375)`, including when the pixel shader was compiled directly from HLSL. This reproduces the WARP discrepancy independently of the translator. The earlier #442 draw tested perspective and screen-linear weights in separate shaders, which also passed here. [Microsoft’s definition of both semantics and vertex ordering](https://github.com/microsoft/DirectXShaderCompiler/wiki/SV_Barycentrics) The PR’s original nine translation/validator tests also passed. The same guest export on base `63bcca43` stops before pipeline creation at offset `0x0` with `barycentrics read directly is not supported`. The opt-in test and three HLSL references are in [this test-only commit](https://github.com/steven-seagull27/VIctory/commit/c0c39ce3246583f784fbc7935bbd3d0df2000c7d). To reproduce from this PR head with Windows SDK DXC installed, run the following. ```sh git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/test/pr3335-dual-barycentric-readback git cherry-pick c0c39ce3246583f784fbc7935bbd3d0df2000c7d cargo test --locked -p victory-shader --lib raw_center_weights_match_native_rasterization -- --ignored --nocapture --test-threads=1 ```
pablogonz12 commented 2026-11-27 17:24:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-27T17:24:43Z.


I tested this change on an RX 9070 XT with RADV using offline translation and pipeline creation. For the affected program I checked, current main refused translation (0/1 pipelines); with this PR applied to current main, translation, SPIR-V validation, and pipeline creation passed (1/1). Not tested on NVIDIA hardware.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224375387 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3335#issuecomment-7224375387). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-27T17:24:43Z. --- I tested this change on an RX 9070 XT with RADV using offline translation and pipeline creation. For the affected program I checked, current main refused translation (0/1 pipelines); with this PR applied to current main, translation, SPIR-V validation, and pipeline creation passed (1/1). Not tested on NVIDIA hardware.
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/3335:upstream-pr/3335'
git switch 'upstream-pr/3335'

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