Shaders: pixel barycentrics through SV_Barycentrics (values and computed interpolation) #453

Closed
AntoninMichelq wants to merge 4 commits from upstream-pr/453 into main
AntoninMichelq commented 2026-11-24 03:34:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AntoninMichelq on 2026-11-24T03:34:31Z.


Requested by 4nto · project thread

Summary

Pixel programs that use their barycentrics in other ways than plain v_interp_* now translate, through SV_Barycentrics.

  1. Barycentrics read as values. Programs that use the I/J VGPRs as plain floats (custom interpolation, math on the weights) failed with "barycentrics read directly". I and J are now channels y and z of an SV_Barycentrics input. 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.
  2. Interpolation with computed barycentrics. v_interp_p1/p2 (and the f16 forms) fed with an i or j that is not the loaded input VGPR failed with "an interpolation with computed barycentrics". Each half is now evaluated as the hardware does, from the vertex values read by attributeAtVertex.

What changed

  • emit/lower.rs, emit/mod.rs, emit/shader.rs, emit/container.rs (commit 1):
    • SV_Barycentrics is declared with the interpolation mode of its kind (perspective or linear; center, centroid or sample). There is one element per mode (semantic index 0 and 1), with the Barycentrics shader flag and SFI0 feature.
    • The element is left unpacked (no row, packing location -1), like other non-packed system values. The DXIL validator refuses it in a row.
    • The VGPRs are loaded as a value on first use, 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.
  • io.rs, emit/lower.rs (commit 2):
    • A computed i or j gives Interp::Weighted: P0 + i (P1 - P0) for the first half, the old dst + j (P2 - P0) for the second.
    • attributeAtVertex needs the element declared constant, so every other interpolation of that attribute row is weighed from its vertices with SV_Barycentrics of its mode. 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. Alone it is still refused.
  • apps/victory/src/translate.rs: the tally counts Interp::Weighted as interpolated.

Open draft PR #281 also emits SV_Barycentrics, but only for direct perspective-center reads and behind an opt-in build feature, because of a concern about the hardware's vertex order. This PR covers all six modes and computed barycentrics, on by default. The two touch the same code in lower.rs.

How it was tested

  • cargo test -p victory-shader (Linux) passes: 65 tests, including 9 new ones (values read as SV_Barycentrics, two modes, interpolation alone, both together, computed barycentrics in io and in the emitter, constant weights, computed and loaded on one attribute, P10 of an interpolated attribute). On Windows these tests also run the DXIL validator when it is present.
  • cargo check --tests -p victory-shader -p victory-gpu and cargo check -p victory for x86_64-pc-windows-msvc (with CARGO_FEATURE_PURE=1) pass.
  • On the game's shader corpus, on an integration stack that includes these commits:
    • "an interpolation with computed barycentrics" went from 207 programs to 0.
    • Vertex and pixel shaders are 100% valid under the Windows DXIL validator.

Where 3D rendering stands on an RX 7600 (Windows 11)

  • In the world's first cutscene, props, characters, cables and vehicle tyres render (seen in a G-buffer view).
  • Ground, roads, buildings, textures, sky and lighting are still missing: the lighting output is black.
  • No GPU hang in the latest world runs of several minutes. About 10,000 draws per frame, at well under 1 fps.

These observations come from the integration stack (upstream main plus many open PRs), not from this branch alone.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66

<!-- greyfinch-sync:Marvisak/VIctory:issue:5465582623 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453). Originally posted by [AntoninMichelq](https://github.com/AntoninMichelq) on 2026-11-24T03:34:31Z. --- <!-- claude-projects-attribution: {"github_login":"AntoninMichelq"} --> _Requested by **4nto** · [project thread](https://claude.ai/code/project/chan_01XYoPEzLL1bj63HP9pniGvs?thread=cmsg_01XYoPEzLL1bj63HP9pniGvsYRPS2v37oeDeGaCHT7dFsi)_ ## Summary Pixel programs that use their barycentrics in other ways than plain `v_interp_*` now translate, through `SV_Barycentrics`. 1. **Barycentrics read as values.** Programs that use the I/J VGPRs as plain floats (custom interpolation, math on the weights) failed with "barycentrics read directly". I and J are now channels y and z of an `SV_Barycentrics` input. 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. 2. **Interpolation with computed barycentrics.** `v_interp_p1`/`p2` (and the f16 forms) fed with an i or j that is not the loaded input VGPR failed with "an interpolation with computed barycentrics". Each half is now evaluated as the hardware does, from the vertex values read by `attributeAtVertex`. ## What changed - `emit/lower.rs`, `emit/mod.rs`, `emit/shader.rs`, `emit/container.rs` (commit 1): - `SV_Barycentrics` is declared with the interpolation mode of its kind (perspective or linear; center, centroid or sample). There is one element per mode (semantic index 0 and 1), with the Barycentrics shader flag and SFI0 feature. - The element is left unpacked (no row, packing location -1), like other non-packed system values. The DXIL validator refuses it in a row. - The VGPRs are loaded as a value on first use, 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. - `io.rs`, `emit/lower.rs` (commit 2): - A computed i or j gives `Interp::Weighted`: P0 + i (P1 - P0) for the first half, the old dst + j (P2 - P0) for the second. - `attributeAtVertex` needs the element declared constant, so every other interpolation of that attribute row is weighed from its vertices with `SV_Barycentrics` of its mode. 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. Alone it is still refused. - `apps/victory/src/translate.rs`: the tally counts `Interp::Weighted` as interpolated. Open draft PR #281 also emits `SV_Barycentrics`, but only for direct perspective-center reads and behind an opt-in build feature, because of a concern about the hardware's vertex order. This PR covers all six modes and computed barycentrics, on by default. The two touch the same code in `lower.rs`. ## How it was tested - `cargo test -p victory-shader` (Linux) passes: 65 tests, including 9 new ones (values read as `SV_Barycentrics`, two modes, interpolation alone, both together, computed barycentrics in `io` and in the emitter, constant weights, computed and loaded on one attribute, P10 of an interpolated attribute). On Windows these tests also run the DXIL validator when it is present. - `cargo check --tests -p victory-shader -p victory-gpu` and `cargo check -p victory` for `x86_64-pc-windows-msvc` (with `CARGO_FEATURE_PURE=1`) pass. - On the game's shader corpus, on an integration stack that includes these commits: - "an interpolation with computed barycentrics" went from 207 programs to 0. - Vertex and pixel shaders are 100% valid under the Windows DXIL validator. ## Where 3D rendering stands on an RX 7600 (Windows 11) - In the world's first cutscene, props, characters, cables and vehicle tyres render (seen in a G-buffer view). - Ground, roads, buildings, textures, sky and lighting are still missing: the lighting output is black. - No GPU hang in the latest world runs of several minutes. About 10,000 draws per frame, at well under 1 fps. These observations come from the integration stack (upstream main plus many open PRs), not from this branch alone. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
DaviTostes commented 2026-11-24 06:55:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T03:42:01Z.


Follow-up: this overlaps #442 (both emit SV_Barycentrics for pixel programs), and the two conflict textually — git merge-tree --write-tree pr442 pr453 reports CONFLICT (content) in crates/victory-shader/src/emit/lower.rs (plus auto-merges in mod.rs/shader.rs). Worth choosing one.

Measured on Arch Linux x86_64 (rustc 1.98.1, cargo test -p victory-shader):

  • this PR (87e9d41): 65 passed, 0 failed.
  • #442 (b6ccc95): 60 passed, 0 failed; it covers direct reads only, while this head also handles computed barycentrics and all six modes.

Not covered here: DXIL validation on Windows (no SM 6.6 device in this Wine prefix) and title shaders (no game data).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121338301 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7121338301). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T03:42:01Z. --- Follow-up: this overlaps #442 (both emit `SV_Barycentrics` for pixel programs), and the two conflict textually — `git merge-tree --write-tree pr442 pr453` reports `CONFLICT (content)` in `crates/victory-shader/src/emit/lower.rs` (plus auto-merges in `mod.rs`/`shader.rs`). Worth choosing one. Measured on **Arch Linux x86_64** (rustc 1.98.1, `cargo test -p victory-shader`): - this PR (`87e9d41`): **65 passed, 0 failed**. - #442 (`b6ccc95`): **60 passed, 0 failed**; it covers direct reads only, while this head also handles computed barycentrics and all six modes. Not covered here: DXIL validation on Windows (no SM 6.6 device in this Wine prefix) and title shaders (no game data).
LocranKing commented 2026-11-24 06:55:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LocranKing on 2026-11-24T04:18:25Z.


Tested on Windows 11 + retail shaders.rpf (1.0.2.1) using victory translate --validate.

Tested

  • Commit: 87e9d41 (pr-453, clean tree)
  • Environment: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, Rust 1.98.1 (x86_64-pc-windows-msvc), Windows SDK 10.0.26100.0 dxil.dll
  • cargo xtask policy: asset policy: 151 files ok
  • cargo test --workspace: 273 passed, 0 failed, 4 ignored
  • victory translate <shaders.rpf> --validate (diag build) vs main (d2a4bae):
    • I/O: 14247 of 14247 vertex and pixel programs raised (up from 14040 of 14247; all 207 I/O: an interpolation with computed barycentrics errors cleared)
    • DXIL (VS/PS): 12453 emitted of 14208; 12347 validated (up from 12272 emitted / 12172 validated on main: +181 emitted, +175 validated)
    • DXIL (CS): 1693 emitted / 1670 validated; DXIL (MS): 8191 emitted / 8129 validated (unchanged)

Not tested: Live gameplay / rendering with these shaders on GPU or WARP.

AI use: Antigravity (Gemini 4 Hydrogen) ran the checks and victory translate --validate and drafted this report from the command outputs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121897523 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7121897523). Originally posted by [LocranKing](https://github.com/LocranKing) on 2026-11-24T04:18:25Z. --- Tested on Windows 11 + retail `shaders.rpf` (1.0.2.1) using `victory translate --validate`. **Tested** - Commit: `87e9d41` (`pr-453`, clean tree) - Environment: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, Rust `1.98.1` (`x86_64-pc-windows-msvc`), Windows SDK `10.0.26100.0` `dxil.dll` - `cargo xtask policy`: `asset policy: 151 files ok` - `cargo test --workspace`: **273 passed, 0 failed, 4 ignored** - `victory translate <shaders.rpf> --validate` (`diag` build) vs `main` (`d2a4bae`): - `I/O`: **14247 of 14247** vertex and pixel programs raised (up from `14040 of 14247`; all **207** `I/O: an interpolation with computed barycentrics` errors cleared) - `DXIL` (VS/PS): **12453 emitted** of 14208; **12347 validated** (up from `12272 emitted` / `12172 validated` on `main`: **+181 emitted, +175 validated**) - `DXIL` (CS): `1693` emitted / `1670` validated; `DXIL` (MS): `8191` emitted / `8129` validated (unchanged) **Not tested:** Live gameplay / rendering with these shaders on GPU or WARP. **AI use:** Antigravity (`Gemini 4 Hydrogen`) ran the checks and `victory translate --validate` and drafted this report from the command outputs.
marquezinii commented 2026-11-24 06:55:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T04:22:33Z.


Ran 87e9d41 on Windows 11 with the SDK's dxil.dll (10.0.26100.0) loaded: cargo test -p victory-shader passes (78). The semantic mapping, the shader flag and SFI0 bit, the element shape and the entry-block placement of loadInput/attributeAtVertex all look right to me.

One case emits a module the validator refuses. barycentric() allows a second SV_Barycentrics element for any second mode, but DXIL allows two only when one is perspective and the other linear. A pixel program that reads both perspective center and perspective centroid I/J as values (SPI_PS_INPUT_ADDR with PERSP_CENTER and PERSP_CENTROID, then v_add_f32 v4, v0, v3, built with the test module's pixel helper) gives:

error: There can only be up to two input attributes of SV_Barycentrics with different perspective interpolation mode.
Validation failed.

two_barycentric_modes_get_two_elements passes because it pairs perspective with linear. The computed-barycentrics path can reach the same state when per-vertex rows use center and centroid. Returning Val::Missing for a second element of the same perspective-ness would at least keep the module valid.

Also, the tests' validate() returns quietly when dxil.dll does not load, so on a machine without the SDK they pass without validating; a message (as constant_color_validates prints) would make that visible.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121960431 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7121960431). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T04:22:33Z. --- Ran `87e9d41` on Windows 11 with the SDK's `dxil.dll` (10.0.26100.0) loaded: `cargo test -p victory-shader` passes (78). The semantic mapping, the shader flag and `SFI0` bit, the element shape and the entry-block placement of `loadInput`/`attributeAtVertex` all look right to me. One case emits a module the validator refuses. `barycentric()` allows a second `SV_Barycentrics` element for any second mode, but DXIL allows two only when one is perspective and the other linear. A pixel program that reads both perspective center and perspective centroid I/J as values (`SPI_PS_INPUT_ADDR` with PERSP_CENTER and PERSP_CENTROID, then `v_add_f32 v4, v0, v3`, built with the test module's `pixel` helper) gives: ``` error: There can only be up to two input attributes of SV_Barycentrics with different perspective interpolation mode. Validation failed. ``` `two_barycentric_modes_get_two_elements` passes because it pairs perspective with linear. The computed-barycentrics path can reach the same state when per-vertex rows use center and centroid. Returning `Val::Missing` for a second element of the same perspective-ness would at least keep the module valid. Also, the tests' `validate()` returns quietly when `dxil.dll` does not load, so on a machine without the SDK they pass without validating; a message (as `constant_color_validates` prints) would make that visible.
SantannaCarlos commented 2026-11-24 08:02:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T07:53:25Z.


Tested on an RTX 4070 (Windows 11, driver 621.01) with victory translate shaders.rpf --validate (1.0.2.1).

I/O raised VS/PS emitted / validated
main (d2a4bae) 14040 / 14247 12272 / 12172
+ this PR 14247 / 14247 12453 / 12347
local stack of open PRs* 14040 / 14247 13342 / 13342
stack + this PR 14247 / 14247 13545 / 13542

* #136 #173 #176 #164 #180 #179 #177 #138 #116 #145 #135 #100.

"an interpolation with computed barycentrics" goes 207 -> 0 and "barycentrics read directly" 6 -> 0 (29 -> 0 on the stack). A per-program diff of the --list runs shows no program that validated before stops validating (+175 on main, +200 on the stack), and no "Invalid record" appears.

I also checked the interpolation on the GPU: full-screen triangles with known per-vertex values in all three vertex rotations, both windings, skewed and with varying w, comparing the hardware's own interpolation with v0 + i*(v1 - v0) + j*(v2 - v0) from GetAttributeAtVertex and SV_Barycentrics. Worst difference 9.1e-8 on the 4070, 1.2e-7 on WARP with uniform w. With varying w WARP disagrees by up to 0.7, but a PC-only shader disagrees with itself the same way, so that is WARP's interpolation, not this lowering. That confirms the vertex order and i = y, j = z. A test like it would be a useful addition; note that a second drawing test module in victory-shader currently fails to resolve the #[cfg(test)] host helpers (Draw, Root) under cargo test --workspace, which is unrelated to this PR.

A row read both per vertex and by hardware interpolation is handled well: rebuilding that row's hardware interpolations from the vertices means nothing emitted renders the provoking vertex by mistake.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7125485046 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7125485046). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T07:53:25Z. --- Tested on an RTX 4070 (Windows 11, driver 621.01) with `victory translate shaders.rpf --validate` (1.0.2.1). | | I/O raised | VS/PS emitted / validated | |---|---|---| | `main` (`d2a4bae`) | 14040 / 14247 | 12272 / 12172 | | + this PR | 14247 / 14247 | 12453 / 12347 | | local stack of open PRs* | 14040 / 14247 | 13342 / 13342 | | stack + this PR | 14247 / 14247 | 13545 / 13542 | \* #136 #173 #176 #164 #180 #179 #177 #138 #116 #145 #135 #100. "an interpolation with computed barycentrics" goes 207 -> 0 and "barycentrics read directly" 6 -> 0 (29 -> 0 on the stack). A per-program diff of the `--list` runs shows no program that validated before stops validating (+175 on `main`, +200 on the stack), and no "Invalid record" appears. I also checked the interpolation on the GPU: full-screen triangles with known per-vertex values in all three vertex rotations, both windings, skewed and with varying w, comparing the hardware's own interpolation with v0 + i*(v1 - v0) + j*(v2 - v0) from `GetAttributeAtVertex` and `SV_Barycentrics`. Worst difference 9.1e-8 on the 4070, 1.2e-7 on WARP with uniform w. With varying w WARP disagrees by up to 0.7, but a PC-only shader disagrees with itself the same way, so that is WARP's interpolation, not this lowering. That confirms the vertex order and i = y, j = z. A test like it would be a useful addition; note that a second drawing test module in victory-shader currently fails to resolve the `#[cfg(test)]` host helpers (`Draw`, `Root`) under `cargo test --workspace`, which is unrelated to this PR. A row read both per vertex and by hardware interpolation is handled well: rebuilding that row's hardware interpolations from the vertices means nothing emitted renders the provoking vertex by mistake.
r4tedx commented 2026-11-24 10:03:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T09:12:23Z.


This PR is in the tester tree now (integration/testers, merge da523fa of 87e9d41), so here is what merging and reviewing it there turned up. Three things, the first good news.

1. What it gains in that tree. Measured on my own copy of the title's shader file, offline: victory translate --host-lanes 32-32 --validate --list before and after the merge, compared program by program (25,889 programs; counts and reasons only):

  • 233 more pixel programs validate and none is lost: 207 that stopped at an interpolation with computed barycentrics and 26 that stopped at barycentrics read directly.
  • 3 more pixel programs that stopped at barycentrics read directly now emit and fail validation with out of bound coord must be undef. All three call calculateLOD, so I read that as another lowering these programs reach now, not this PR's. I have not reproduced it with a synthetic program yet.

That agrees with the counts on main posted above (207 and 6 cleared, +175 validated).

2. Two cases where 87e9d41 emits a module dxil.dll refuses. Both have a test in the tree that fails without the fix and passes with it (commit 55c2938, 13 lines of code in emit/lower.rs and emit/mod.rs):

  • Two sample positions of one kind. A program that reads the centre's and the centroid's perspective i and j as values gets two SV_Barycentrics elements of the same kind. DXIL takes one perspective and one linear. The limit in Lower::barycentric counts elements (index >= 2), not kinds. The fix refuses the second of a kind with barycentrics of two sample positions.
  • A console signature that already has an SV_Barycentrics row. The row is carried over, packed, also under a program that only interpolates, and the validator refuses the module. The fix drops console rows of kind 28 before lowering, which declares what the program reads.

By the same offline count, neither case occurs in the title's shader file: the fix changes the outcome of 0 of the 25,889 programs. So it is correctness for programs outside that file, not a gain. You are welcome to take the commit, or to tell me it is wrong.

3. One thing about drawing tests, now that CI runs on a machine without a GPU. In review here, a program with both a perspective and a linear SV_Barycentrics drew the expected values on an RTX 5070 and wrong ones on WARP, and so did DXC's own module for the same shader, so that is WARP's. A drawing test of that shape would fail in CI through no fault of the lowering. Programs with one kind drew correctly on both.

Tested here on an RTX 5070: cargo test --workspace on the tree with this PR and the fix, 442 passed, 5 ignored. The title was not launched; point 1 used its shader file offline as described, and nothing from it is in the tree. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7127097557 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7127097557). Originally posted by [r4tedx](https://github.com/r4tedx) on 2026-11-24T09:12:23Z. --- This PR is in the tester tree now ([`integration/testers`](https://github.com/r4tedx/VIctory/tree/integration/testers), merge `da523fa` of `87e9d41`), so here is what merging and reviewing it there turned up. Three things, the first good news. **1. What it gains in that tree.** Measured on my own copy of the title's shader file, offline: `victory translate --host-lanes 32-32 --validate --list` before and after the merge, compared program by program (25,889 programs; counts and reasons only): - 233 more pixel programs validate and none is lost: 207 that stopped at `an interpolation with computed barycentrics` and 26 that stopped at `barycentrics read directly`. - 3 more pixel programs that stopped at `barycentrics read directly` now emit and fail validation with `out of bound coord must be undef`. All three call `calculateLOD`, so I read that as another lowering these programs reach now, not this PR's. I have not reproduced it with a synthetic program yet. That agrees with the counts on `main` posted above (207 and 6 cleared, +175 validated). **2. Two cases where `87e9d41` emits a module `dxil.dll` refuses.** Both have a test in the tree that fails without the fix and passes with it (commit [`55c2938`](https://github.com/r4tedx/VIctory/commit/55c2938), 13 lines of code in `emit/lower.rs` and `emit/mod.rs`): - *Two sample positions of one kind.* A program that reads the centre's and the centroid's perspective i and j as values gets two `SV_Barycentrics` elements of the same kind. DXIL takes one perspective and one linear. The limit in `Lower::barycentric` counts elements (`index >= 2`), not kinds. The fix refuses the second of a kind with `barycentrics of two sample positions`. - *A console signature that already has an `SV_Barycentrics` row.* The row is carried over, packed, also under a program that only interpolates, and the validator refuses the module. The fix drops console rows of kind 28 before lowering, which declares what the program reads. By the same offline count, neither case occurs in the title's shader file: the fix changes the outcome of 0 of the 25,889 programs. So it is correctness for programs outside that file, not a gain. You are welcome to take the commit, or to tell me it is wrong. **3. One thing about drawing tests, now that CI runs on a machine without a GPU.** In review here, a program with both a perspective and a linear `SV_Barycentrics` drew the expected values on an RTX 5070 and wrong ones on WARP, and so did DXC's own module for the same shader, so that is WARP's. A drawing test of that shape would fail in CI through no fault of the lowering. Programs with one kind drew correctly on both. Tested here on an RTX 5070: `cargo test --workspace` on the tree with this PR and the fix, 442 passed, 5 ignored. The title was not launched; point 1 used its shader file offline as described, and nothing from it is in the tree. AI-assisted.
slint6614-dev commented 2026-11-24 10:03:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T09:24:27Z.


Measured on the full retail shader pack (26,503 containers) with victory translate --validate --pipelines (pipelines created on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. This PR conflicts with current main (lower.rs), so it was measured on its own base, against main 1f858b0 before #612 (VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129).

  • VS/PS 12453 / 12347 (+175 validated): all 207 "I/O: an interpolation with computed barycentrics" and the 6 "barycentrics read directly" refusals are gone.
  • New: "an opaque lane mask" 29 → 61, 3 validator "out of bound coord must be undef." and 3 signature-row interpolation-mode errors.
  • CS and MS unchanged; every emitted program gets a pipeline on the RX 9070.
  • #442 covers only the 6 direct reads (+10 validated on current main).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7127371111 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7127371111). Originally posted by [slint6614-dev](https://github.com/slint6614-dev) on 2026-11-24T09:24:27Z. --- Measured on the full retail shader pack (26,503 containers) with `victory translate --validate --pipelines` (pipelines created on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. This PR conflicts with current main (`lower.rs`), so it was measured on its own base, against main 1f858b0 before #612 (VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129). - VS/PS 12453 / **12347** (+175 validated): all 207 "I/O: an interpolation with computed barycentrics" and the 6 "barycentrics read directly" refusals are gone. - New: "an opaque lane mask" 29 → 61, 3 validator "out of bound coord must be undef." and 3 signature-row interpolation-mode errors. - CS and MS unchanged; every emitted program gets a pipeline on the RX 9070. - #442 covers only the 6 direct reads (+10 validated on current main).
MichaelSmithAI commented 2026-11-24 11:04:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T10:16:30Z.


Follow-up on the three pixel programs that reached the calculateLOD validator error. We reproduced the same error on main ffe310e with source-built pixel shaders using 1D-array and 2D-array textures. The emitter passes the array slice as a coordinate. DXIL expects only the spatial coordinates for this query, including the unclamped form. A plain 2D texture provided the control.

The standalone fix and portable regression are in 26f915d. Microsoft DXV accepts all three generated modules with the fix. If you still have the same three programs locally, a before/after validator count on your #453 stack would tell us how many this covers. The synthetic inputs establish the array case; the resource dimensions in the three reported programs are still unknown.

On an RTX 4090 through Wine/vkd3d, both corrected array shaders and independent DXC HLSL returned clamped LOD 1 and unclamped LOD −32 in all 64 pixels with constant coordinates and sampler MinLOD 1.

AI-assisted implementation and verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7128553933 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7128553933). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T10:16:30Z. --- Follow-up on the three pixel programs that reached the `calculateLOD` validator error. We reproduced the same error on main `ffe310e` with source-built pixel shaders using 1D-array and 2D-array textures. The emitter passes the array slice as a coordinate. DXIL expects only the spatial coordinates for this query, including the unclamped form. A plain 2D texture provided the control. The standalone fix and portable regression are in [26f915d](https://github.com/MichaelSmithAI/VIctory/commit/26f915d8e5892f2ef6e928deb94a771eb1cee02b). Microsoft DXV accepts all three generated modules with the fix. If you still have the same three programs locally, a before/after validator count on your #453 stack would tell us how many this covers. The synthetic inputs establish the array case; the resource dimensions in the three reported programs are still unknown. On an RTX 4090 through Wine/vkd3d, both corrected array shaders and independent DXC HLSL returned clamped LOD 1 and unclamped LOD −32 in all 64 pixels with constant coordinates and sampler MinLOD 1. AI-assisted implementation and verification.
walterwallaceson commented 2026-11-24 11:04:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by walterwallaceson on 2026-11-24T10:56:07Z.


A short in-game data point for this PR, from Windows 10 with an RTX 3070 on main 8e79c80 plus a stack of open PRs (#439, #483, #493, #688, #704 and others; details on #392).

In a captured frame in the world, every draw into one full-resolution R32G32_UINT target is dropped: 35 draws, all from one pipeline, whose pixel program fails with barycentrics read directly. That is the reason this PR addresses, so it should bring the whole pass back.

I couldn't test it yet. This PR's head is on main ffe310e, which includes #566, and that conflicts with #439's stack in emit/lower.rs, emit/mod.rs and structure.rs. Once #439 is rebased past #566, I'll run the title with this PR and report whether the pass draws.

I'm testing with Claude's help, and Claude drafted this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129437487 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7129437487). Originally posted by [walterwallaceson](https://github.com/walterwallaceson) on 2026-11-24T10:56:07Z. --- A short in-game data point for this PR, from Windows 10 with an RTX 3070 on `main` `8e79c80` plus a stack of open PRs (#439, #483, #493, #688, #704 and others; details on #392). In a captured frame in the world, every draw into one full-resolution `R32G32_UINT` target is dropped: 35 draws, all from one pipeline, whose pixel program fails with `barycentrics read directly`. That is the reason this PR addresses, so it should bring the whole pass back. I couldn't test it yet. This PR's head is on `main` `ffe310e`, which includes #566, and that conflicts with #439's stack in `emit/lower.rs`, `emit/mod.rs` and `structure.rs`. Once #439 is rebased past #566, I'll run the title with this PR and report whether the pass draws. I'm testing with Claude's help, and Claude drafted this comment.
AntoninMichelq commented 2026-11-24 12:04:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AntoninMichelq on 2026-11-24T11:05:34Z.


Thanks, that's a very useful data point. A full-resolution R32G32_UINT target written by 35 draws from one pipeline looks like a visibility-style pass, so getting it back could matter a lot.

Since your comment, the branch has main merged in (3bc83d0). It also has 88b34a4, which refuses a program that reads two perspective barycentric modes, so it no longer produces invalid DXIL. I understand you need #439 rebased past #566 before you can test. When you do, a before/after count of draws into that target would be great.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129644460 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7129644460). Originally posted by [AntoninMichelq](https://github.com/AntoninMichelq) on 2026-11-24T11:05:34Z. --- Thanks, that's a very useful data point. A full-resolution R32G32_UINT target written by 35 draws from one pipeline looks like a visibility-style pass, so getting it back could matter a lot. Since your comment, the branch has main merged in (3bc83d0). It also has 88b34a4, which refuses a program that reads two perspective barycentric modes, so it no longer produces invalid DXIL. I understand you need #439 rebased past #566 before you can test. When you do, a before/after count of draws into that target would be great.
catminou4 commented 2026-11-24 14:04:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T14:04:11Z.

Review: APPROVED


Substantial feature done carefully. What I verified in the diff:

Semantics. eval_channel with Eval::Weights computes P0 + i·(P1−P0) + j·(P2−P0) via fmad, matching the GFX10 barycentric interpolation the PR description documents (P0 = provoking vertex, i/j from SV_Barycentrics channels y/z). vertex_input reads the constant-declared element through attributeAtVertex and sets flags::BARYCENTRICS. The per_vertex/interpolated predicates correctly decide when an attribute row must be read per-vertex vs. left to the normal interpolated path, and Interp::Vertex still refuses non-provoking reads (vertex != 2 guard).

io.rs classification. Pair.barycentric becoming Option<Barycentric> is the right shape: computed i or j downgrades each half to Interp::Weighted independently, and push_pair records the first halves with a dedup guard so a half isn't registered twice. The kind.is_some_and(...) logic only keeps the paired kind when every first half reads the same kind's i — conservative in the right direction.

Validator constraints. The "one perspective + one linear SV_Barycentrics element max" errors match the DXIL rule quoted in the tests, and the element is deliberately left unpacked (packing location −1) with a comment explaining the validator refuses it in a row.

Tests. 9 new tests cover the matrix (values-as-barycentrics, two modes, interpolation alone, both together, computed barycentrics in io and emitter, constant weights); the computed_barycentrics_evaluate_each_half test pins the Weighted classification exactly.

Verified locally: test-merge with current main (ffe310e) clean; cargo test -p victory-shader --locked (macOS arm64, rustc 1.98.1) → 106 passed / 0 failed / 1 ignored. Actual barycentric values on hardware are Windows-gated (valu_tests), so the Windows lane should confirm the i=y/j=z mapping on real titles — but the lowering structure and classification are platform-independent and green here.

One triage note for the maintainer: open draft #281 touches the same lower.rs barycentrics code (opt-in, perspective-center only). This PR covers all six modes on by default and supersedes it functionally; whichever lands second will need a rebase.

<!-- greyfinch-sync:Marvisak/VIctory:review:6040629077 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#pullrequestreview-6040629077). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T14:04:11Z. **Review:** APPROVED --- Substantial feature done carefully. What I verified in the diff: **Semantics.** `eval_channel` with `Eval::Weights` computes P0 + i·(P1−P0) + j·(P2−P0) via `fmad`, matching the GFX10 barycentric interpolation the PR description documents (P0 = provoking vertex, i/j from `SV_Barycentrics` channels y/z). `vertex_input` reads the constant-declared element through `attributeAtVertex` and sets `flags::BARYCENTRICS`. The `per_vertex`/`interpolated` predicates correctly decide when an attribute row must be read per-vertex vs. left to the normal interpolated path, and `Interp::Vertex` still refuses non-provoking reads (`vertex != 2` guard). **io.rs classification.** `Pair.barycentric` becoming `Option<Barycentric>` is the right shape: computed i or j downgrades each half to `Interp::Weighted` independently, and `push_pair` records the first halves with a dedup guard so a half isn't registered twice. The `kind.is_some_and(...)` logic only keeps the paired kind when every first half reads the same kind's i — conservative in the right direction. **Validator constraints.** The "one perspective + one linear SV_Barycentrics element max" errors match the DXIL rule quoted in the tests, and the element is deliberately left unpacked (packing location −1) with a comment explaining the validator refuses it in a row. **Tests.** 9 new tests cover the matrix (values-as-barycentrics, two modes, interpolation alone, both together, computed barycentrics in io and emitter, constant weights); the `computed_barycentrics_evaluate_each_half` test pins the `Weighted` classification exactly. Verified locally: test-merge with current main (`ffe310e`) clean; `cargo test -p victory-shader --locked` (macOS arm64, rustc 1.98.1) → **106 passed / 0 failed / 1 ignored**. Actual barycentric *values* on hardware are Windows-gated (`valu_tests`), so the Windows lane should confirm the i=y/j=z mapping on real titles — but the lowering structure and classification are platform-independent and green here. One triage note for the maintainer: open draft #281 touches the same `lower.rs` barycentrics code (opt-in, perspective-center only). This PR covers all six modes on by default and supersedes it functionally; whichever lands second will need a rebase.
r4tedx commented 2026-11-24 15:04:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T14:30:43Z.


@MichaelSmithAI the before/after count you asked for, on the three programs themselves.

The fix from your 26f915d (a level-of-detail query passes only its spatial coordinates) is in the tester tree now, as commit 2a61b8e of update 7. Offline over my copy of the title's shader file (victory translate --host-lanes 32-32 --validate --list, 25,889 programs, compared program by program):

  • before: 3 pixel programs fail validation with out of bound coord must be undef;
  • after: all 3 validate, and no program in the file fails with that message any more. Nothing else changes with the fix.

So it covers every case of it in that file. I cannot say from the count which array dimension the three use.

One thing about how it went in: your commit's test builds Lower::new(&parts, &bad) directly, and that signature differs in the tree (the wave64 stack adds arguments), so the tree has its own test instead: a 1D-array and a 2D-array image_get_lod, each run through dxil.dll. It fails with the validator's message when the change is taken out. The commit message credits your commit for the fix.

The title was not launched; this used its shader file offline as described. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134494850 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7134494850). Originally posted by [r4tedx](https://github.com/r4tedx) on 2026-11-24T14:30:43Z. --- @MichaelSmithAI the before/after count you asked for, on the three programs themselves. The fix from your `26f915d` (a level-of-detail query passes only its spatial coordinates) is in the tester tree now, as commit [`2a61b8e`](https://github.com/r4tedx/VIctory/commit/2a61b8e) of update 7. Offline over my copy of the title's shader file (`victory translate --host-lanes 32-32 --validate --list`, 25,889 programs, compared program by program): - before: 3 pixel programs fail validation with `out of bound coord must be undef`; - after: all 3 validate, and no program in the file fails with that message any more. Nothing else changes with the fix. So it covers every case of it in that file. I cannot say from the count which array dimension the three use. One thing about how it went in: your commit's test builds `Lower::new(&parts, &bad)` directly, and that signature differs in the tree (the wave64 stack adds arguments), so the tree has its own test instead: a 1D-array and a 2D-array `image_get_lod`, each run through `dxil.dll`. It fails with the validator's message when the change is taken out. The commit message credits your commit for the fix. The title was not launched; this used its shader file offline as described. AI-assisted.
Yaekai commented 2026-11-24 17:04:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yaekai on 2026-11-24T16:11:35Z.


Independent test & review on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head 88b34a4:

  • cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 112 passed, 0 failed.
  • cargo clippy -p victory-shader -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): barycentrics read directly is not supported refusals dropped to 0 with no regressions. Ready to merge!
<!-- greyfinch-sync:Marvisak/VIctory:comment:7137266750 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7137266750). Originally posted by [Yaekai](https://github.com/Yaekai) on 2026-11-24T16:11:35Z. --- Independent test & review on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head `88b34a4`: - `cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests`: 112 passed, 0 failed. - `cargo clippy -p victory-shader -- -D warnings`: 0 warnings. - Live GTA VI (`1.0.2.1`, `--console series-s`, 19-min world run): `barycentrics read directly is not supported` refusals dropped to **0** with no regressions. Ready to merge!
Marvisak commented 2026-11-25 01:07:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:19:06Z.


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/io.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148382906 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7148382906). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:19:06Z. --- <!-- victory-triage v1 head=88b34a447350eeb1e747be84e4204dbb3955c58c verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/io.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
iGoldenNinja commented 2026-11-25 10:07:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by iGoldenNinja on 2026-11-25T09:37:36Z.


I checked 88b34a447350eeb1e747be84e4204dbb3955c58c together with the exact 64-bit atomics change e2624b3384813a444067fe9ba93dfd131473a63c from #2241. The cherry-pick onto this head applied without manual edits. Hardware was an RTX 5080, driver 617.14 and Windows 11 Pro 25H2 build 26200.9974, with Rust 1.98.1 MSVC and dxil.dll 1.9.2609.5.

In the same 168-program pixel set that I tested for #2241, six shaders still failed on barycentrics read directly with the atomics change alone. All six emitted, validated and created D3D12 pipelines with this PR added. A full rerun of translate --jobs 2 --validate --pipelines --list then produced 168/168 emitted, validated and created pipelines, including all 162 from the earlier run. The combined test reached offline pipeline creation. Pinned results and tested revisions

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158584325 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7158584325). Originally posted by [iGoldenNinja](https://github.com/iGoldenNinja) on 2026-11-25T09:37:36Z. --- I checked `88b34a447350eeb1e747be84e4204dbb3955c58c` together with the exact 64-bit atomics change `e2624b3384813a444067fe9ba93dfd131473a63c` from #2241. The cherry-pick onto this head applied without manual edits. Hardware was an RTX 5080, driver 617.14 and Windows 11 Pro 25H2 build 26200.9974, with Rust 1.98.1 MSVC and `dxil.dll` 1.9.2609.5. In the same 168-program pixel set that I tested for #2241, six shaders still failed on `barycentrics read directly` with the atomics change alone. All six emitted, validated and created D3D12 pipelines with this PR added. A full rerun of `translate --jobs 2 --validate --pipelines --list` then produced **168/168** emitted, validated and created pipelines, including all 162 from the earlier run. The combined test reached offline pipeline creation. [Pinned results and tested revisions](https://github.com/iGoldenNinja/victory-fork/blob/baa2cfb5b4ad53f4298a67c1f8f8e589854a2c1c/docs/victory-pr2241-5080.md#combined-retest-with-pr-453)
upstream-sync closed this pull request 2026-11-25 20:05:01 +00:00

Pull request closed

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!453
No description provided.