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

Closed
github-bot wants to merge 4 commits from gh-pr/453/head into gh-pr/453/base
Owner

@⁠AntoninMichelq on GitHub · 2026-11-24 03:34 UTC · original
AntoninMichelq:up/pixel-barycentrics → main · +729 −72 · 6 files · 4 commits · closed without merging

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

**@⁠AntoninMichelq** on GitHub · 2026-11-24 03:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/453) `AntoninMichelq:up/pixel-barycentrics` → `main` · +729 −72 · 6 files · 4 commits · closed without merging <!-- 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
Pixel programs that use the I/J VGPRs as plain values (custom
interpolation, math on the weights) failed with "barycentrics read
directly". They are now channels y and z of an SV_Barycentrics input
(SM 6.1+, the emitter targets 6.6) declared with the interpolation mode
of their kind (perspective/linear, center/centroid/sample), one element
per mode (semantic index 0 and 1), with the Barycentrics shader flag and
SFI0 feature. GFX10 interpolates P0 + i (P1 - P0) + j (P2 - P0) with P0
the provoking vertex, which the host's barycentrics weight as vertex 0,
so i = y and j = z.

The VGPRs are loaded on first use as a value, so programs that only feed
them to v_interp_* declare nothing new. A console signature's own
SV_Barycentrics row (D3D name 23) is parsed and reused. Pull-model
barycentrics stay unsupported.

SV_Barycentrics is left unpacked (no row, packing location -1), like
other non-packed system values: the DXIL validator refuses it in a row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
v_interp_p1/p2 (and the f16 forms) fed with an i or j that is not the
loaded input VGPR now evaluate each half as the hardware does: P0 + i
(P1 - P0) for the first, the old dst + j (P2 - P0) for the second, with
the vertex values read by attributeAtVertex. That needs the element
declared constant, so every other interpolation of the same attribute
row is weighed from its vertices with SV_Barycentrics of its mode, and
flat reads stay loadInput of the provoking vertex. v_interp_mov of P10
and P20 reads P1 - P0 and P2 - P0 the same way when the program also
interpolates the attribute (so the hardware holds the deltas); alone it
is still refused.

The translate command's tally counts Interp::Weighted as interpolated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
lower.rs: keep the PR's lazy barycentric VGPR inputs next to main's
`Reg::S(n)` arm for uninitialized SGPRs. mod.rs: the barycentric test
helper passes the structure to resource::track, which now takes it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
DXIL allows at most two SV_Barycentrics input elements, one perspective
and one linear. A program reading both perspective center and centroid
I/J as values declared two perspective elements, which the validator
refuses ("There can only be up to two input attributes of
SV_Barycentrics with different perspective interpolation mode").

The second mode of the same kind is now an Unsupported reason rather
than a second element. Reusing the first element would hand centroid
reads center weights (or the reverse), which differ on edge pixels: a
silent wrong value. Before this PR such reads were refused anyway.

Test: center + centroid values are refused; centroid alone still
translates with one element.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:04:36 +00:00
github-bot closed this pull request 2026-11-26 04:04:36 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 03:42 UTC · original

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

**@⁠DaviTostes** on GitHub · 2026-11-24 03:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7121338301) 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).
Author
Owner

@⁠LocranKing on GitHub · 2026-11-24 04:18 UTC · original

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.

**@⁠LocranKing** on GitHub · 2026-11-24 04:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7121897523) 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.
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 04:22 UTC · original

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.

**@⁠marquezinii** on GitHub · 2026-11-24 04:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7121960431) 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.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-24 07:53 UTC · original

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.

**@⁠SantannaCarlos** on GitHub · 2026-11-24 07:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7125485046) 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.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-24 09:12 UTC · original

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.

**@⁠r4tedx** on GitHub · 2026-11-24 09:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7127097557) 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.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 09:24 UTC · original

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).
**@⁠slint6614-dev** on GitHub · 2026-11-24 09:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7127371111) 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).
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 10:16 UTC · original · edited 2026-11-24 10:24 UTC

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.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 10:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7128553933) · edited 2026-11-24 10:24 UTC 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.
Author
Owner

@⁠walterwallaceson on GitHub · 2026-11-24 10:56 UTC · original

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.

**@⁠walterwallaceson** on GitHub · 2026-11-24 10:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7129437487) 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.
Author
Owner

@⁠AntoninMichelq on GitHub · 2026-11-24 11:05 UTC · original

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.

**@⁠AntoninMichelq** on GitHub · 2026-11-24 11:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7129644460) 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.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-24 14:30 UTC · original

@⁠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.

**@⁠r4tedx** on GitHub · 2026-11-24 14:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7134494850) @⁠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.
Author
Owner

@⁠Yaekai on GitHub · 2026-11-24 16:11 UTC · original

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!
**@⁠Yaekai** on GitHub · 2026-11-24 16:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7137266750) 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!
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:19 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 00:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7148382906) <!-- 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)_
Author
Owner

@⁠iGoldenNinja on GitHub · 2026-11-25 09:37 UTC · original

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

**@⁠iGoldenNinja** on GitHub · 2026-11-25 09:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/453#issuecomment-7158584325) 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)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!453
No description provided.