Shaders: a loop retry that still needs 64 lanes leaves widen its blocks (02384a60fda6f2d0 translates) #560
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-28T00:55:22Z.
Rebased on main (
32ecacf). Main has fixed #539 in its own way since. In8fc2254,emittranslates a program once more, with no loop branches taken together, when the first try fails. That brought the underwater program back.It did not bring back
02384a60fda6f2d0(CS_DefragHeap_ComputeRelocations): starnotes-xj's run on8fc2254still refused it, and this PR makes it translate (see below). On32ecacf, this PR's own test still fails without the change.The 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. 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.emit_oncethen went on to its approximate forms. When those failed too, the program was refused with "no wave32 lowering for this wave64 program", unless main's second try, with no loop branches taken together, translated it.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_once, 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.
What it changes on main
ghptc's
split_wave_lds_loopprogram, withVICTORY_WAVE_WHY=1, on32ecacf:WAVE64-WIDE 0 branches taken wave-wide: [], goes on tolocal waves (APPROXIMATE, any mask): wave Some(64), and fails. Main's second try then findsWAVE64-WIDE 1 branches taken wave-wide: [B1(s_cbranch_execz)]and logsWAVE-LOOPS left out: the program translates without them.WAVE64-WIDE 1 branches taken wave-wide: [B1(s_cbranch_execz)], thenwave-wide branches: wave Some(32). There is no second try.In the first try, the approximate local waves come after
widen. So without the change, a program whose approximate form translates gets that form, and the second try never runs. With it,widengets there first.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(32ecacf). It fails:the `if` taken wave-wide: waves of 32, leftSome(64), rightSome(32). 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, on32ecacftoo.emit::lds_loop_tests, written by ghptc, who reproduced the failure independently (see the comment below; the second commit):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. Before8fc2254it failed without the fix, with "no wave32 lowering for this wave64 program". On32ecacfit passes either way, through main's second try (above).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: 338 passed, 7 ignored (the new tests included).--all-targets, default and--all-features): nothing in the changed lines. The two errors left are main's own:clippy::let_and_returnin a test ofemit/mod.rs, andclippy::manual_is_multiple_ofatshadow.rs:1740.The shader cache key (
env!("VICTORY_TRANSLATOR")) follows the translator's source, so translations cached before this change are made again.Checked by others (before the rebase)
64d4931with this PR, the underwater scene is drawn again. #539 is closed: main's8fc2254brings it back too.8fc2254:02384a60fda6f2d0(vfx_triangleClip:CS_DefragHeap_ComputeRelocations) was refused on every run, with "no wave32 lowering for this wave64 program". With this PR it translates.VICTORY_LEAVE_OUT, for its cost: 11.85 ms a frame).VICTORY_WAVE_SPLIT=0), the translator alone still took it, so this PR is enough on its own for that program.Not checked yet on
32ecacf: whether02384a60fda6f2d0is still refused there without this PR. I have asked in a comment below.No game files, dumps or extracted data are included.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ghptc on 2026-11-28T01:13:37Z.
@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:
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CuteBooty on 2026-11-28T01:14:20Z.
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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by starnotes-xj on 2026-11-28T07:24:08Z.
Confirmed on a 32-lane host, and this one has a visible effect.
Card: RTX 4060 Laptop 8 GB, Windows, GTA VI 1.0.2.1, latest
main(55 commits,8fc2254).02384a60fda6f2d0(vfx_triangleClip:CS_DefragHeap_ComputeRelocations) is the program that places the faces' meshes. With #490 (the launchers stop leaving it out) it started being compiled and was refused every run:With this PR merged, the same run goes:
and the faces come back in the cafe cutscene (a child and a man in a pink shirt, both black-headed before).
Attribution: I also merged #259 (the split-wave64 fallback), so to tell which one takes it I ran the translator on its own, with the fallback switched off:
So on this title #560 alone is enough — the split fallback is not reached for this program. The remaining refusal in a whole run is
6b82bc7d22016cb5(the meshlet collector, which #101 names as still open).Our save point with it:
save-2026-11-28-facesin starnotes-xj/VIctory-NVIDIA.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-28T19:37:15Z.
@starnotes-xj, this branch is now rebased on main
32ecacf(head41bc85e).Main has changed the translator 16 times since
8fc2254, #101 among them. So I can't tell from here whether02384a60fda6f2d0is still refused on32ecacfwithout this PR.Could you run your check from before once on
32ecacfalone, then once with this branch?The two
warm-uplines are enough.VICTORY_WAVE_SPLITis no longer needed: #259 was closed, so main has no split fallback.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-28T19:49:26Z.
This is in main since
41d9f62("Merge pull request #560", with7c81ea6keeping the wave64 test whole). It came from this PR's commits from before my rebase,52a4d0eandf629b52. So I pointed the branch back atf629b52, and GitHub closed the PR on that push. Nothing of it is left out.@starnotes-xj, no branch is needed for the check I asked for: main has the fix now. Run it on main
923e38cor later:A "1 translated now" for
02384a60fda6f2d0is all that's needed.Pull request closed