Shaders: track uniform LDS reads and exact operand widths in lane_uniform (#16) #36
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!36
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-36"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@adriaespii on GitHub · 2026-11-24 20:44 UTC · original
adriaespii:fix/lane-uniform-lds-read→main· +207 −19 · 1 files · 1 commits · openAddresses the
v_readfirstlane_b32wave-uniformity gap reported in #16 (part 1) without needing an opt-in override flag.What changed
In
crates/victory-shader/src/emit/lower.rs(lane_uniform):ds_read*, excluding_d16): whends_read*(gds: false, no guard) reads from a VGPR address already insame, mark its destination register(s) as wave-uniform._d16forms are excluded because they preserve the other half of the destination VGPR.Operand::Vectorread range: filterinst.readsbyreg..reg + dwordsinstead ofx >= reg. Becauseir.rsincludes the previous value of the destination VGPR ininst.reads(for EXEC guards),x >= regswept up the old uninitialized/per-lane destination register wheneverdst > src(e.g.v_add_nc_u32 v8, s17, v2) and poisoned uniformity. Also check alldwordsforOperand::Scalar.first_lane_read_of_uniform_lds_load_lowers_on_wave32): verifies underTEST_HOST_WAVE = 32that a divergentds_read_b32from a uniform address +v_add_nc_u32+v_readfirstlane_b32lowers cleanly, while the same shader with a per-lane address (v0) is still refused witha first-lane read where not every lane runs.Tested
x86_64-pc-windows-msvc)cargo clippy --workspace --all-targets -- -D warnings: 0 warningscargo test --workspace: 496 passed, 0 failed, 7 ignored (victory-shader: 211 passed, 0 failed, 2 ignored)Not tested
XboxBvhBuilder.dllshaders or live game runs (no game files on this machine)AI use
lane_uniformbugs, wrote the fix and unit test, and ranclippyand the workspace test suite.@rostaddotcc on GitHub · 2026-11-24 21:20 UTC · original
Verified at
d964ec7on a Linux host (CachyOS, x86-64, no GPU needed for these):cargo test -p victory-shader— 171 passed, 0 failed, 2 ignored (173 listed).cargo test -p victory-pipeline— 4 passed.cargo xtask policy— 169 files ok.cargo xwin build --release -p victory --target x86_64-pc-windows-msvc— clean, 16.8 s.The change adds one test for 113 lines in
lane_uniform. Worth saying in the description whether that test covers #16's own shapes — thef16box bounds and thev_cvt_f32_f64/ whole-wavev_add_f64sums — or only the uniform-read machinery. #16's reporter is on a 32-lane host, so nobody with a wave64 machine can confirm the fix by running the game; the unit test is the only evidence there is, and it should name the case it settles.One thing I can check here that a wave64 host cannot: whether the wave64 path is unchanged for programs that were already correct. If the diff can perturb uniform tracking on a 64-lane host, the 26 698-program corpus is the place to see it — I have that translate run on disk and can diff the emitted containers before/after this patch on this machine (~10 min, no game). Say the word and I will post the count.
@adriaespii on GitHub · 2026-11-24 21:24 UTC · original
Thanks for the great catch and for verifying the 52/52 builder translation + DXIL validation @ryotdev!
Fixed in
87d674f(rebased ontomain4e17478):start..endregister range tou16for bothOperand::VectorandOperand::Scalarso operands touchingv255(v255single-word andv[254:255]pairs) are not truncated byu8saturation.lane_uniform_handles_v255_and_high_pair_operandscovering both the uniformv255case and the varyingv[254:255]high-word shift case.cargo clippy --workspace --all-targets -- -D warnings(0 warnings) andcargo test --workspace(498 passed, 0 failed, 7 ignored;victory-shader: 212 passed, 0 failed, 2 ignored). Ready for another look!AI use: Antigravity (Gemini 4 Neon) applied the fix, wrote the regression test, and ran clippy/tests.
@adriaespii on GitHub · 2026-11-24 21:26 UTC · original
Thanks for checking on Linux @rostaddotcc! To clarify both points:
v_readfirstlane_b32wave-uniformity refusal on 32-lane hosts, which@ryotdevconfirmed takesXboxBvhBuilder.dllfrom 49/52 to 52/52 emitted and DXIL-validated). It does not touchv_cvt_f32_f64/v_add_f64(covered by #9) or thef16box-bounds crash.host_max_wave() >= 64),exchangeisNone, solane_uniformis never called (uniformstays empty). The emitted wave64 containers are unchanged by construction.AI use: Antigravity (Gemini 4 Neon) drafted this reply.
@CDR-0000 on GitHub · 2026-11-24 21:40 UTC · original
NVIDIA test of this PR at
87d674f: RTX 3080 Ti (32-lane waves) — 52/52 builder programs with host pipelines on the card, no change elsewhere in the retail pack, and the builder starts in game.Setup: RTX 3080 Ti 12 GB, driver 32.0.16.1742; Ryzen 7 7800X3D; 32 GB; Windows 11 Pro 26300; Rust 1.98.1 MSVC, release. Tree: fork
main4e17478+ upstream #454 + this PR, merged cleanly.87d674f)XboxBvhBuilder.dll,VICTORY_HOST_MAX_WAVE=32 victory translate --validate --pipelines@0x99160…)--validatecargo test -p victory-shaderon the cardfirst_lane_read_of_uniform_lds_load_lowers_on_wave32,lane_uniform_handles_v255_and_high_pair_operands)VICTORY_BVH_BUILDER=1(3 runs, atd964ec7)The title then crashes 7–14 s later in the prologue — the #16 crash, which also happens on a 64-lane RX 9070 XT without this PR, so it is outside this PR's scope; details and a write-back trace in #16.
Written with Claude Code (Claude Opus 5.5); the runs are mine.
@arminkhaleghirod on GitHub · 2026-11-24 21:42 UTC · original
Merged onto main
90228a7and ranvictory translate --validateover the full title (26,148 programs) on Windows 11 / RTX 4080. Changes against main, by failure reason:No change: every failure count is the same as main, and no new reason appears. So no regression in translation. What this PR changes at run time isn't covered by this check.
@Revens2 on GitHub · 2026-11-25 05:13 UTC · original
Build check only: this PR merges cleanly on main
c96b4f2and the integration build of eight PRs (#115 #66 #36 #144 #147 #141 #139 #130) compiles (diagnostics profile). In the game, that combo was run alone 3 times (900 s,VICTORY_RELAY=2, scripted input): one run to the end (median 4.95 fps, about 4.9k draws per frame, against 4.84-5.04 fps on main), one title breakpoint0x80000003at about 157 s after a failed dstorage request (the pattern is explained on #115), one device removed (0x887A0005) at about 160 s that did not repeat in the two other runs. Nothing is proven for this PR alone: it was not run on its own,cargo testwas not run on the combo, and nothing was checked on the title side of its change. Not verified.@ryotdev on GitHub · 2026-11-24 21:02 UTC · original
On
crates/victory-shader/src/emit/lower.rsline 483 (outdated):For a legal source pair
v[254:255], the exclusive end is 256. Theu8addition saturates to 255 and drops the high word. A shift that copies a per-lanev255into its low result then gets classified as wave-uniform. A single-word read of a uniformv255also fails the proof in the other direction.I put a cherry-pickable fix and a hand-written regression test directly on top of your PR. It checks each decoded source dword, including the last register. The varying-high-word case fails on this head. With the fix, both the varying and constant cases pass, and the shader library suite passes 172 tests with 2 ignored. Fix and regression test
I also ran the builder through the offline translator with
VICTORY_HOST_WAVE=32and DXIL validation. Main at4e17478emitted and validated 49/52 compute programs. This PR reached 52/52, and all 52 outputs remained byte-identical after the fix. This measures shader generation and validation. GPU execution, lighting and frame times remain untested here.AI-assisted review and test.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.