Shaders: a loop leaves with the host wave when a VCC test of a lane compare says so #196
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!196
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-196"
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?
@JaumeMarRib on GitHub · 2026-11-24 22:26 UTC · original
JaumeMarRib:pr/loop-exit-wave-vote→main· +73 −0 · 1 files · 1 commits · openProblem
The structurisation turns a branch on a wave-wide mask test into a branch on the lane's own bit. That is right where compiled code only skips work, or where the tested value is the same in every lane, but not for a loop exit on
s_cbranch_vccz/vccnzof a compare that differs between lanes: the console leaves with the whole wave as soon as one lane meets the exit, while the per-lane rule keeps a lane whose own test never holds looping up to the iteration limit.The title's clustered-light pixel shaders do exactly that: the outer loop walks light-mask words from the first lane's start and leaves when the word index equals some lane's end (
v_cmp_eq_u32 vcc, s79, v56; s_cbranch_vccz). In a wave that mixes clusters, a lane whose end lies before the first lane's start never matches and runs the loop (and the light loop inside it) about 2^20 times. On an RTX 5070, single draws of one mesh group with these shaders took 100-130 ms in the first mission's intro (VICTORY_GPU_TIMING=1), and lists of them ended inDXGI_ERROR_DEVICE_HUNG.Change
crates/victory-shader/src/emit/lower.rs, +73 lines: where one way of such a branch stays in a loop around the block (its header, or plain jumps to it) and the other leaves, the exit also holds when it holds in some lane of the host wave (WaveActiveAnyTrue), as the console's wave-wide test does. A lane still leaves on its own exit, so a wave of helper lanes only (which wave votes leave out) keeps the old rule. Other branches keep the lane rule, and branches inStructured::wide, which already carry the wave-wide answer, are left alone.Verification
cargo clippy --workspace --all-targets --locked -- -D warningsclean;cargo test --workspace --lockedpasses.🤖 Generated with Claude Code
@rocobalt1 on GitHub · 2026-11-24 23:13 UTC · original
This is the fix for the trade-off I reported in #62: with it, a 4060 Ti at
VICTORY_SHADER_LOOP_LIMIT=256draws the room and the hair, which it could not do before.Setup: RTX 4060 Ti 8 GB, driver 32.0.16.1656, Ryzen 9 5900X, Windows 11;
4e17478+ #32 #77 #81 #9 #40 #83 #38 #51 #234 #188 + this PR (48747d8), diag build,--console series-s,VICTORY_SHADER_LOOP_LIMIT=256,VICTORY_NO_WATCHDOG=1, fresh data dir.TdrDelay=60.So on this card the missing geometry was the loop exit, exactly as #62 suspected, and not a refused draw - the four refusals remain the same four (transpose vec/mat, shadow cascades alpha, shallow water reduce, water volumetrics).
Nothing else regressed that I can see: the hair stays correct at 256 in the same frame that gained the ceiling, which is the pairing that was impossible before.
No game data; counts only.
@luisaugustz on GitHub · 2026-11-25 00:23 UTC · original
Correction to my RX 9070 XT comment above: please disregard its results. They were not measured with this PR.
My build of this PR failed on our base (
578d459+ staging fix): the patch usesStructured::wide, which that base does not have. My run script ignored the failed compile and kept using the previous executable, an unrelated experiment of mine (exact-copy texture views, the one I reported as negative on #3). So the "with this PR" and "half-wave vote" rows, the blow-out, and the G-buffer remarks all describe that other build, not this PR. I have not tested this PR on an RX 9070 XT yet.Sorry for the noise. If I get it building (it probably needs the change that adds
Structured::wide), I'll post real numbers in a new comment.AI-assisted (Claude Code).
@luisaugustz on GitHub · 2026-11-24 23:50 UTC · original · edited 2026-11-25 00:23 UTC
RETRACTED: these results were not measured with this PR, see the correction below.
RX 9070 XT (RDNA 4): with this PR the cell's wall and the character textures reach the G-buffer, but the lit picture is blown out and torn; a per-console-wave vote does not change that
A data point from AMD, since the PR is verified on NVIDIA so far.
Setup: RX 9070 XT, Adrenalin 32.0.32029.2010, Ryzen 7 5800X, 32 GB, Windows 11; fork
578d459+ a staging-release fix + this PR's commit365c3b2(applied cleanly), diag build, Series X,VICTORY_SHADER_LOOP_LIMIT=256,VICTORY_CUT_WRITES=1, texture queue 1024 MB / 1000 ms withVICTORY_TEXTURE_BUDGET_MB=6144, DRED off, 41 AMDCS_RaytracingResolveskips + 2 others. Same prologue, 10 minutes each, cold shader cache for each new executable.waveActiveBallotdword by lane index for console wave32,waveAnyTruefor wave64)One run each, so read the first two rows as a lead and not a proof; I know the cell shell is intermittent on other cards.
So on this card the PR does something real before lighting (the wall and the shirt colour exist in the albedo plane only with it), and something wrong in the lit output. My first guess was the vote's scope: if the host runs the console's 32-lane pixel shaders as wave64 (as PastiiJay found for the purple blocks),
waveAnyTruewould span two console waves. Testing the vote over the console wave's own half did not change the picture, so that is not it.What I have not done: find which of the 21 changed pixel shaders is responsible, or check whether a lane's early exit leaves a light sum that the following code treats as clustered-light output. If it would help, I can test the PR with only the four slowest programs changed, by hash, to see whether the blow-out follows a subset.
Counts and settings only; no game data.
AI-assisted (Claude Code): measured on this machine with a diag build.
@ryotdev on GitHub · 2026-11-25 01:01 UTC · original
I found a branch-direction case in
wave_loop_exiton365c3b2. Whens_cbranch_vccnzis the back edge, the wave must keep looping while any lane still has work. The current lowering stops the entire host wave as soon as any lane is done.I reproduced this with a hand-written wave32 compute shader on Windows D3D12 WARP. The 32 lanes alternate between end values 1 and 2. A shared counter increments, compares against each lane’s end, then branches back on VCCNZ while the counter is below an end. The PR writes 1 in all 32 lanes. The guest result is 2 in every lane. The complementary VCCZ loop exits at 1 as expected. Both cases finish in at most two iterations.
The fix and regression test use the structuriser’s existing
wave_anyand account forexit()inverting the predicate and swapping successors. Both cases pass on WARP after the fix. The portable shader suite passed 170 tests, with 2 ignored.For workload context, the PR’s rule fired in 11 of 455 submitted pixel shaders across three local prison checkpoint frames. All 11 already used the correct polarity for their loop. None of the 20 shader stages from our 15 highest-ranked timed pipelines selected the rule, so I have no FPS measurement to attribute to this fix. AI-assisted.
@JRamos1993 on GitHub · 2026-11-25 06:56 UTC · original
Offline check on the retail shader pack: no program gained or lost, but 1271 programs' DXIL changes.
victory translate --validate --listover the title's full shader pack (26,084 programs) on an RTX 5090,main310c6ebagainst this head merged onto it. I added a local DXIL hash on each validated line (two runs of one build hash the same):I have not looked at what changes in them or checked it in game.
AI use: Claude Code with Claude Opus 5.5 ran the pack and wrote this. Nothing from the title is in it.
@MamaLeVrai on GitHub · 2026-11-25 10:59 UTC · original
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
365c3b2intomainf85101bin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails with exactly the errorsmainitself has on this machine (placed_filler_twins,depth_written, a sort; PR #841 fixes them); with--all-featuresit fails with the same number of errors asmain(4). This PR adds none and removes none.cargo test --workspace --locked: run 1: one failure, run 2: 555 passed, 0 failed, 11 ignored (mainalone: 555 passed). The failure isindirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which fails onmainitself most runs here (PR #849 fixes its assertion; see issue #850). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
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.