Shaders: a loop retry that still needs 64 lanes leaves widen its blocks (fixes #539) #560
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/trustno1-coder--VIctory-NVIDIA!560
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-560"
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?
@kibagami-nc on GitHub · 2026-11-28 00:55 UTC · original
kibagami-nc:fix/loop-retry-keeps-wider-needs→main· +281 −3 · 3 files · 2 commits · openThe problem
64d4931added a retry inemit_program(crates/victory-shader/src/emit/mod.rs): a console wave64 compute program on a host of 32-lane waves is translated once more with its loop branches taken by each host wave together, and that translation is given "if it needs no wider waves" than the first (w <= *wave).When both translations still ask for 64 lanes,
64 <= 64holds, so the retry was taken, andlower::take_needs()dropped the blocks the first lowering had named. Those blocks are whatwidenuses: it takes the per-lane branches around them wave-wide, again and again, until the program fits 32-lane waves. With nothing named,widenstopped at waves of 64, andemitrefused the program with "no wave32 lowering for this wave64 program".This hits programs that have a per-lane loop and that need 64 lanes somewhere else, for instance an LDS exchange between the two host waves inside a per-lane
if.The change
The retry is given only when it fits the host. That check is
too_wide, the same test as the refusal inemit, which now calls it. Otherwise the first translation and its named blocks are kept, exactly as when the retry fails.Retries that do fit are given as before: 64 lanes to 32, or 32 to 32.
#539
#539 shows the same error from
64d4931on. Compute program926c46bab3b86bd6, first bound in dives, translates onf3534e6and no longer does on64d4931, and the scene under water is not drawn. The comment abovescene_kernelnamesCS_TransmissionVolumetricsSubmergedas a program that only translates on 32-lane hosts throughwiden(29 branches).Checked in game by the reporter of #539 (comment below), on their RTX 3070 with the same save and the same dive:
926c46bab3b86bd6translates again;One leftover they saw: under a pier, square screen tiles switch for a moment between the water's haze and the unhazed scene. Whether that is this program's widened form or something separate is open.
Tests
emit::wave64_tests::a_loop_retry_that_still_needs_64_lanes_leaves_the_widening_its_blocks:if ((t & 31) < s1)writes its sum to LDS and adds lanet ^ 32's, which is in the other host wave.main.widenends atSome(64), and withVICTORY_WAVE_WHY=1the log shows the retry taken. WithVICTORY_LOOPS_WAVE=0(no retry) the same test passes.widenreachesSome(32). On an RTX 5070 Ti (32-lane waves) the output matches the console model for 4 sets of root constants.emit::lds_loop_tests, written by ghptc, who reproduced the failure independently (see the comment below; added inf629b52):emit(). The tests go throughemit()with the submerged kernel's selector.split_wave_lds_loop. It translates on a 32-lane host, with no GPU needed. Without the fix it fails with "no wave32 lowering for this wave64 program".tile_pixels_match_the_console_wave. It is ignored by default, because it needs a 32-lane SM 6.6 card. Every channel's bits match a CPU model of the console wave: 64 of 64 pixels for both programs on an RTX 5070 Ti.cargo test -p victory-shader --locked: 291 passed, 5 ignored (the new tests included).cargo clippy -p victory-shader --all-targets --locked -- -D warnings, and the same with--all-features: no warnings.Workspace-wide
cargo clippy --workspace -- -D warningsalready stops on lintsmainhas (see #425, #265 and #86). This change adds no warning.The shader cache key (
env!("VICTORY_TRANSLATOR")) follows the translator's source, so translations cached before this change are made again.No game files, dumps or extracted data are included.
@ghptc on GitHub · 2026-11-28 01:13 UTC · original
@kibagami-nc, I independently reproduced the shader translation failure and tested your fix at
52a4d0e33on an RTX 5070 (driver 620.73.4, Proton Experimental, vkd3d-proton). Would you like to include the additional fixture in this PR? The test-only patch below applies to your head.Your test calls
widen()directly and checks a raw-buffer exchange after a lane-varying loop with four sets of constants. The additional fixture callsemit()with the existing submerged-kernel selector, exchanges LDS values inside the loop, then writes an 8 × 8 RGBA32F texture. It includes a control shader without the exchange. The translation test runs on Linux without a GPU. The opt-in D3D12 test checks the bits of every RGBA channel against a CPU model of the 64-lane console wave.f3534e6b064d4931b352a4d0e33The automated bisect identified
64d4931b3. Your own four-input test also executed on the card and passed. This confirms the translator regression and its repair for these synthetic shaders. The association with926c46bab3b86bd6and the underwater image in #539 still needs a same-save gameplay check on the reporter’s setup. The fixture shares the published selector digest and uses independently written instructions.Test-only patch and reproduction commands
With the diff applied, run:
@CuteBooty on GitHub · 2026-11-28 01:14 UTC · original
Tested on the card from #539: this brings the underwater scene back.
64d4931b3+ this PR's commit (52a4d0e33, cherry-picked) + the same local commits as in #539. Diagnostics profile, started withvictory.exe run, Series S, 1920x1080, no DLSS,VICTORY_BUFFERS_AHEAD=0, all translator switches at their defaults.Log, same shader as in the issue:
No
shader does not translatefor it any more, nodropped … compute 926c46bab3b86bd6lines, noERRORlines, no device loss in the first seven minutes, with two dives.cargo test -p victory-shader wave64: 15 passed, including the new test.What I see: under water the scene is drawn and looks decent most of the time. There is one leftover artifact, at its worst under a pier: for a moment, square screen tiles swap between the water's blue haze and the un-hazed scene, so sand and dark openings are cut out in blocks with stair-stepped edges. It depends on where I look: looking down at the sea floor the picture is clean; it gets far worse when looking level or up towards the surface. I can add screenshots of both (the worst frame I could catch, and a clean one of the floor). I do not know whether that is this shader's widened form or something separate; I never saw a working dive on
64d4931b3to compare with.One run, one card. Not tested:
play, your release exe, DLSS or frame generation with this commit, Series X.Measurements and this comment were prepared with an AI assistant (Claude Code); the run was played on my machine.
Shaders: a loop retry that still needs 64 lanes leaves widen its blocks (likely #539)to Shaders: a loop retry that still needs 64 lanes leaves widen its blocks (fixes #539)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.