Shaders: first-lane reads of values alike in a console wave let the structure builder run on 32-lane GPUs #497
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!497
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-497"
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?
@justrealyme on GitHub · 2026-11-25 01:40 UTC · original
justrealyme:wave-alike-first-lane→main· +289 −44 · 2 files · 2 commits · openWhat
On a GPU with 32-lane waves (NVIDIA), a console wave64 program runs as two host waves, and a
v_readfirstlanewhere not every lane runs is refused:a first-lane read where not every lane runs. Three programs of the ray-tracing structure builder (XboxBvhBuilder.dllat0x99160,0x9a830,0x9be80; compute39321a95223001ed,77360df21e12ea43,9fc111d3be79364f) stop that way, and since the builder runs all or none (builder_runs), it can never run on a 32-lane GPU:the ray-tracing structure builder stays off: ... missing=3 of=53.Their shape: a prefix over wave totals in a 512-thread group. Each wave scans its lanes, its last lane writes the total to LDS, a barrier, then under
if (id >> 6 != 0)each wave loops over the totals before it, lanes leaving at their own wave's index, withv_readfirstlaneof the running sum each iteration. The sum and the conditions are the same in every lane of a console wave, so each host wave can take its own first lane, butlane_uniformskipped guarded instructions, loop-carried phis and LDS reads, so it could not tell.lane_uniformnow runs to a fixed point and also counts:allitself is unchanged, since it also decides where group barriers go);Its result is still only used for
v_readfirstlanein the two-host-wave form.Checked
a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loop(wave64_tests.rs): the same shape in 256 threads (four console waves, with a read across the two host waves so they exchange). It fails onmainwith exactly this refusal, and passes with the change on an RTX 5070 Ti, driver 621.40: every thread gets the sum of the waves before its own.VICTORY_HOST_WAVE=32 victory translate --validateover the title's shader pack, executable and builder DLL, before and after, comparing every emitted shader byte for byte: the only programs that change are these three (now emitted and validated; compute 2,718 to 2,721 of 2,734) and one other builder program (0x95220), whose only first-lane read is ofid >> 6and now skips an exchange that gave the same value. Nothing else changes.cargo test -p victory-shaderon this branch (on top ofc96b4f2): 215 passed. Clippy (--all-features) clean.VICTORY_BVH_BUILDER=1, the builder now runs:the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53. The title then crashes within about 15 s (access violations in title code), with and withoutVICTORY_BVH_QUARANTINE=1, so the builder stays off by default, and this does not make anything visible yet. It removes the blocker that kept the builder from being tried at all on NVIDIA.AI-assisted (Claude Code). Built and run on my machine with my own copy; no game data in the change or here.
🤖 Generated with Claude Code
@ryotdev on GitHub · 2026-11-25 05:32 UTC · original
I found a case where the new proof in
lane_uniformclassifies a varying thread ID as uniform. RDNA2'sv_lshrrev_b32uses the low five bits of the shift count. With inline 32, lanes 0 and 32 produce 0 and 32. Treating this as a shift past the wave width can let the two host halves choose different values for a first-lane read. The builder's shift by six still qualifies. AMD RDNA2 ISA, �12.7I put a cherry-pickable fix and regression test directly on your head. The test decodes a hand-written shift for each inline integer 0�64 and checks the proof against all 64 lane IDs. It fails on the original head at shift 32. With the fix the shader library suite passed on Linux (172 passed, 2 ignored), and
cargo xtask policypassed. This checks the translator proof; I didn't run a game or GPU for this correction.AI-assisted review.
@justrealyme on GitHub · 2026-11-25 07:51 UTC · original
Thanks, you're right: the b32 shift takes only the low five bits of the count, so an inline 32 (or anything with the low bits under 6) isn't a shift past the wave. I fast-forwarded the branch to your commit
9e24afaas is.Checked on an RTX 5070 Ti (driver 621.40, Windows 11): the shader library suite passes, 216 passed and 3 ignored, including your new test and the GPU test from the first commit. I've taken the same commit into my own fork too.
AI-assisted (Claude Code).
@Dathinel on GitHub · 2026-11-25 22:27 UTC · original
Measured the synthetic prefix test on an RTX 3050 Laptop (32-lane hardware), including the 512-thread group size described for the builder. With the proof from
9e24afaon our local Series S branch, both DXIL variants validated, both compute PSOs were created, and every output matched the CPU prefix of (10 + wave index). At 256 threads: 256/256 matched, last wave 33. At 512 threads: 512/512 matched, last wave 91. On the same base without the proof the 256-thread fixture failed to lower at offset 144. This tests arithmetic and cross-half communication on synthetic input; it does not exercise a live acceleration structure. AI-assisted.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.