Skip to content

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

Closed
AntoninMichelq wants to merge 4 commits into
Marvisak:mainfrom
AntoninMichelq:up/pixel-barycentrics
Closed

AntoninMichelq wants to merge 4 commits into
Marvisak:mainfrom
AntoninMichelq:up/pixel-barycentrics

Conversation

@AntoninMichelq

Copy link
Copy Markdown

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

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
@DaviTostes

Copy link
Copy Markdown

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

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

@LocranKing

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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 added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…entrics)

By AntoninMichelq. Conflicts and what was kept:

- emit/lower.rs (the interpolation's packing): Marvisak#176's `half_inputs`
  lookup, with the PR's `total` closure after it.
- io.rs: Marvisak#179's `Halves` made on demand
  (`halves.get_or_insert_with(|| Halves::new(p))`), with the PR's
  `push_pair`; both sides' tests.
- emit/mod.rs (the PR's test helper `pixel`): Marvisak#566's per-lane argument
  of `resource::track` and Marvisak#223's `Target` argument of `emit`; the
  helper still fails on resources, then I/O, then structure.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
… of the console's

Two cases where Marvisak#453 emitted a module dxil.dll refuses, found in review:

- A program that reads the barycentrics of two sample positions of one
  kind as values (centre and centroid, both perspective) declared two
  SV_Barycentrics of that kind. DXIL takes one perspective and one
  linear. It now stops with `barycentrics of two sample positions`; the
  old limit counted elements, not kinds.
- A console input signature with an SV_Barycentrics row of its own kept
  that row, packed, also under a program that only interpolates. The row
  is dropped: lowering declares what the program reads.

Tests (emit/mod.rs, barycentric_tests): the refusal by name; a console
row under a program that interpolates and under one that reads i and j,
each validated. Each fails with its half of the change taken out.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…out)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@slint6614-dev

Copy link
Copy Markdown

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.
  • Shaders: read a pixel program's barycentrics as SV_Barycentrics #442 covers only the 6 direct reads (+10 validated on current main).

@MichaelSmithAI

MichaelSmithAI commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
@walterwallaceson

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Author

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.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
… initialised, no group sync at a barrier only some lanes reach)

By FibbS6. One textual conflict in emit/lower.rs (its `divergent_barriers`
beside Marvisak#453's `interp_mode`; both kept).

One change to the PR's behaviour, in `Lower::new`: its fence-only barriers
are not applied in the console flow of the wave64 stack (Marvisak#233, Marvisak#320,
Marvisak#439). There every lane of a wave runs every block, so the lanes come to a
barrier together, and the stack relies on the group sync to order one
wave's LDS accesses. Per lane, the PR's rule stands.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
`image_get_lod` of an array texture passed the array slice as a
coordinate; DXIL's CalculateLOD takes the spatial ones and wants the rest
undefined, and dxil.dll refused the module ("out of bound coord must be
undef"). Three of the title's pixel programs reached this once Marvisak#453 let
them past their barycentrics.

The fix is MichaelSmithAI's (commit 26f915d on their fork, reported on
Marvisak#453); its test there is written against main's
`Lower::new` and does not build in this tree, so the test here is one
for this tree's helpers: a 1D-array and a 2D-array query, each validated.
It fails with the validator's message when the change is taken out.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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

Callimann8 added a commit to Callimann8/VIctory-fork that referenced this pull request Nov 24, 2026
…trics)

Conflict in shader.rs: both feature flags kept (barycentrics, typed
64-bit atomics). Its test helper passes Target::ANY to emit (Marvisak#233).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Callimann8 added a commit to Callimann8/VIctory-fork that referenced this pull request Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yaekai

Yaekai commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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!

mpDom pushed a commit to mpDom/VIctory that referenced this pull request Nov 24, 2026
`image_get_lod` of an array texture passed the array slice as a
coordinate; DXIL's CalculateLOD takes the spatial ones and wants the rest
undefined, and dxil.dll refused the module ("out of bound coord must be
undef"). Three of the title's pixel programs reached this once Marvisak#453 let
them past their barycentrics.

The fix is MichaelSmithAI's (commit 26f915d on their fork, reported on
Marvisak#453); its test there is written against main's
`Lower::new` and does not build in this tree, so the test here is one
for this tree's helpers: a 1D-array and a 2D-array query, each validated.
It fails with the validator's message when the change is taken out.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
mpDom pushed a commit to mpDom/VIctory that referenced this pull request Nov 24, 2026
…interpolation with its fix)

Onto 6f1c30b (the tree's update 4, the black-scene branch and Marvisak#704).

One conflict, emit/lower.rs, where inputs are loaded on first use: this
branch's spill arguments (`Reg::Spill`, Marvisak#489) and Marvisak#453's barycentric
VGPR inputs are both left for first use.

`cargo test --workspace --no-fail-fast -- --test-threads=4`, run once on
the RTX 5070 and WARP while offline translate runs shared the CPU:
victory-shader 225 passed, 1 ignored; victory-gpu 97 passed, 1 ignored,
1 failed (frame::tests::waits_end_on_ticks_and_count_frames, a timing
test that fails under load); every other crate passes. Not run in the
title.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
The tester tree (upstream main ffe310e plus its PRs, update 8; see its
INTEGRATION.md) ran 11-25 minutes in the world on an RTX 5070 without a
device removal. Where both sides carry the same PR (the wave64 stack
#223/#233/#320 with #439 and #180, #454, #336, #259, #331 and others), the
tester tree's newer head is taken; our own work and the PRs only we
merged are kept.

Conflicts, file by file:

- descriptor/host.rs: the tester layout (`spare`, the guard slot after the
  dynamic slots, `free_table`, the capped sampler heap). A capped view
  heap keeps `capped_reserve()` dynamic slots, now 2^18 by default (the
  tester measurement, and our 91fed158), still `VICTORY_DYNAMIC_SLOTS` in
  diagnostics builds; uncapped hosts keep our 2^19. Our slot statistics
  (TAKEN/PEAK/SHORT), the bindless plan cache (`CommittedRegions`,
  `timed_valid_title_address`, `timed_find`, `title_bounds`) and the
  revision triple are kept beside the tester's `guard_slot`.
- Buffer states: the tester tree's buffer-state tracker (#334: every list
  moves host copies of title memory between GENERIC_READ and
  UNORDERED_ACCESS and back to common before it closes) and depth twins
  (#469) are taken. #40's enhanced/legacy indirect barriers (the indirect
  prelude, `use_indirect_buffers`, the title buffer handoff mirrored in
  `host_barrier`) cannot share buffers with that tracker and are dropped;
  #40's argument checks (`byte_len`, exact spans, overflow-safe clamp
  shader, aligned counts) stay. `indirect::bound` and #282's
  `rectangles` go through `buffer_state`, and `indirect::execute` (#334)
  replaces `done`. #178's DXC fallback compiles both of our passes.
  Our segments (#387: `close` ends the segment, `close_native` closes a
  native list) carry the tracker: each native list returns its buffers
  to common and its twins to their depth targets, and each prelude also
  holds our texture uploads.
- shadow.rs: our write flow (`queue_write`, one `snapshot` after the
  batch's refreshes, `finish_writes`, the unchanged-page cache) with
  #261's copy-back that also gives the snapshot the title's bytes; its
  tests run through our flow.
- pipeline/make.rs: #275's per-frame budget and per-pipeline wake pair,
  with our compute waits (a dispatch waits for its pipeline, up to 20 s).
- pipeline/library.rs: the tester version (#347, #275's saver thread);
  our concurrent-write test kept. shader_cache.rs: our byte-returning
  cache API with #358's "translated, only not kept".
- draw.rs: #493's root SRV tables; where no table can stand in, our
  drop of a draw whose root view is unset or outside title buffers. Our
  refusal of a table offset past the capped heap stays.
- resource.rs: `HostTexture` has both our `staged` generation and the
  depth twin.
- Shaders: the tester's lower.rs for the wave64 stack, #160's image
  sampling (it covers our #73 and #136 sample forms) and #453/#587; kept
  from our side: #136's preference for an image or buffer use of a
  descriptor read as data and its `s_buffer_` arm, #422's nearest-even
  narrowing (also for #169's d16 loads and #453's interpolation), #452's
  spin-wait limit, #391's LDS limit, #302's spilled root arguments (now in
  `NativeProgram::translation_ir`), #136's PSV0 interpolation beside the
  tester's row harmonisation. split_tests.rs, lane_read_loop_tests.rs and
  docs/wave64-on-wave32.md are the tester versions (the same PRs at newer
  heads).
- Tests: #483's heap guard dwords filled in our GPU tests of #200
  (v_div_scale) and #437 (scalar loads from a raw view), which read
  through the guard slot otherwise; #334's debug-layer test passes an
  offset to our `indirect::bound`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simnJS pushed a commit to MiamiGame/XTP that referenced this pull request Nov 24, 2026
…ted interpolation)

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, one element per mode, 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; it is left unpacked, as the validator wants. A
second perspective (or linear) mode is refused: DXIL allows one of
each, and reusing the first would give centroid reads center weights.

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; alone it is still refused. Interpolations
with operand modifiers (VOP3 abs/neg) are refused rather than lowered
without them.

XTP adaptation: the hunks of emit/lower.rs went to emit/lower/input.rs
(S0b), merged with #592/#621's packed inputs (a padding half is the
float 0 now that halves are evaluated as floats); the first-use hook
went to `Lower::get` (emit/lower/operand.rs) and the join of a read phi
to emit/lower/flow.rs (3 lines, granted for this port); emit/mod.rs and
emit/container.rs get one line each for the system value; the upstream
tests (emit/mod.rs there) are in input.rs's tests. Review: a plain
32-bit interpolation keeps its loaded bits as before (the upstream
merge round-tripped them through a float, which changed 8,966
translations for nothing). Left as a shortcut, from upstream: triangles
only (on lines and points the console's i and j are not checked
against the host's weights).

Survey (shaders.rpf, any host, every translation validated): 23,161 ->
23,371 translated, 210 new (175 with computed barycentrics, 35 reading
them directly), 204 accepted by dxil.dll; the 6 others stop at errors
of their own (3 "out of bound coord must be undef", 3 interpolation
modes packed in one row); none lost, no validator verdict changed.
74 translations that existed change, all still accepted. 33 programs
past these blockers stop at the next one (32 at an opaque lane mask).
Without the flow.rs hook, 87 of them stopped at "a join of mismatched
values".

Ported from Marvisak/VIctory#453 (head 88b34a447350eeb1e747be84e4204dbb3955c58c) by AntoninMichelq
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…with the resolution of its conflicts with Marvisak#176 and Marvisak#1293

Marvisak#453 evaluates the halves of an interpolation on their own when i or j is
computed (SV_Barycentrics, Interp::Weighted). Marvisak#1293 (in the stack) follows
plain v_mov_b32 copies to find the barycentric of a pair, and Marvisak#176 (in the
stack) pairs packed 16-bit pixel inputs through half_inputs. The conflicts
were in io.rs (the pairing), emit/lower.rs (the interpolation lowering and
two spots of the phi and helper code) and emit/shader.rs (the feature
bits). See the pull request text for how each was resolved.

Marvisak#1293's test interpolation_follows_agreeing_phis_and_rejects_mismatched_or_modified_copies
asserted that a computed i (a phi of i and j, a negated copy) is refused;
with Marvisak#453 it is supported as a Weighted pair, so those two assertions now
expect Weighted halves.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(391 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…with the resolution of its conflicts with Marvisak#176 and Marvisak#1293

Marvisak#453 evaluates the halves of an interpolation on their own when i or j is
computed (SV_Barycentrics, Interp::Weighted). Marvisak#1293 (in the stack) follows
plain v_mov_b32 copies to find the barycentric of a pair, and Marvisak#176 (in the
stack) pairs packed 16-bit pixel inputs through half_inputs. The conflicts
were in io.rs (the pairing), emit/lower.rs (the interpolation lowering and
two spots of the phi and helper code) and emit/shader.rs (the feature
bits). See the pull request text for how each was resolved.

Marvisak#1293's test interpolation_follows_agreeing_phis_and_rejects_mismatched_or_modified_copies
asserted that a computed i (a phi of i and j, a negated copy) is refused;
with Marvisak#453 it is supported as a Weighted pair, so those two assertions now
expect Weighted halves.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(391 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

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

@iGoldenNinja

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.