Shaders: lane reads and writes where lanes branch differently run in the console flow #320
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/320"
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 Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T02:16:41Z.
Current head
0fa6af4, integrated withmainatffe310e. The lane-read tests use structured resource tracking. The translator retains both the mask information used by console flow and the reach conditions used by the descriptor tracker. Local Windows verification:cargo test --workspace --locked(359 passed, 6 ignored) and all-target, all-feature Clippy with warnings denied. No title run for this update. AI-assisted (Codex).Fixes #225. Stacked on #233 (which is stacked on #223); the last three commits are new here (
36e05dc,c223206,fd8b8fe; before the rebases ontomain(now8e79c80) on 2026-11-24 they were6ec772f,4c197a0,a5ba4a4, the ids testers' reports use; replayed unchanged, except that a new upstream test gets the field this PR adds tolower::Parts; CI's two clippy commands are clean at this head; the lane-read loop test now takes its devices from the SM 6.6 hardware-adapter list and skips when there is none, a fix first made at the top of the stack and folded in here).What
On the console
v_readlaneandv_writelaneignore EXEC, and a wave runs a loop while any of its lanes does. The per-lane form runs branches and loops per lane, so a lane that left a loop or skipped a branch is not there to be read or written, and never sees the scalars set inside. Two measured cases onmain:v_writelaneto lane 40 inside a branch only lanes below 20 take: lane 40 is never written (Radeon).A compute program with
v_readlaneorv_writelaneand at least one branch that is not uniform now runs in the console flow from #233 on every host: every lane of a wave runs every block, EXEC guards the vector instructions, and branches are the console'ss_cbranch_*, taken wave-wide.Parts::per_lane_only), so nothing that translated before is refused.ds_(b)permute.SGPR spills (
v_writelaneto stash an SGPR,v_readlanerestoring it) stay on main's per-lane form, since each restore is proven to be its SGPR: with the console's wave size on a host that runs it (asmain), and with no wave size on a 32..32 host, where each restore is lowered as its SGPR. Spill-only wave64 programs therefore now translate on 32-lane hosts instead of being dropped, and spill + DPP programs run split rather than in the console flow. Test:sgpr_spills_across_a_divergent_branch_stay_per_lane.docs/wave64-on-wave32.mdshows as deleted in this diff: #233 folded that plan intodocs/architecture.md, and the merge carries that up.Small generalisations of #233's helpers:
console_lanemasks with the console wave size (waves of 32 too),console_ballotreturns the host wave's ballot when nothing is split, andv_readfirstlanereads no high EXEC word in waves of 32.The second commit closes a gap in the console flow itself, found through the test report on #233: the loop form compilers emit keeps finished lanes in an exit mask that starts as a constant 0, and the console flow's mask joins took only masks derived from EXEC or a VALU result, so such a loop stopped with
a lane-mask join of an untracked mask.Structured::othersnow gives the lane's bit of constant and scalar-built masks for those joins. The per-lane form is unchanged.How this relates to other open PRs
#269 makes scalars leave divergent loops and branches as the wave left them, with maxima over the host wave. In the console flow scalars are the wave's own by construction: with a local switch sending #269's four test programs through it, all four are exact on both adapters here, where #269's two scalar tests give per-half values on hosts that form 32-lane waves (details). This PR does not select the console flow for those programs.
In compiled shaders, the usual source of
v_writelane/v_readlaneoutside whole-wave sections is SGPR spill slots: a scalar parked in a lane of a VGPR and read back later, whatever EXEC holds. #54 and #189 resolve spills at constant lanes in SSA, so the lane accesses disappear and the control flow stays per lane. Where that applies it is cheaper than this PR, and the two compose: with spills resolved first, fewer programs would ask for the console flow. This PR covers what is left: lanes computed at run time, and reads of another lane's own data.Not verified
No game files and no console hardware were used: the expected values follow the ISA's EXEC and lane-access semantics. I did not measure how many of the title's programs take this path, or its cost on them. A tester's whole-title translate found 21 more compute pipelines than #233, 20 of them in the validation class above. The console flow guards instructions where the per-lane form branches around them, so a divergent program does more work per lane.
The fallback to the per-lane form has no test of its own; I found no hand-assembled program that the console flow refuses and the per-lane form takes.
Vertex, pixel and mesh programs are unchanged.
Tested
Windows 11, an NVIDIA RTX 5070 (32..32) and an AMD Radeon iGPU (RDNA2, 32..64) in one machine, hand-assembled GFX10, every lane checked:
emit/lane_read_loop_tests.rs(the #225 repro, no longer ignored): exact on both adapters in waves of 32 and of 64 (on the RTX 5070 the wave64 program runs in two halves).split_tests::lane_writes_reach_lanes_outside_the_branch: exact on both. With the new condition switched off it fails on the Radeon (lane 40 keeps 1).split_tests::loops_run_while_any_lane_of_the_console_wave_doesnow checks 64-lane hosts too.split_tests::loops_with_an_exit_mask_grown_from_zero(the compilers' loop form, a lane read in each iteration, the exit mask counted afterwards): refused on the RTX 5070 before the second commit, exact on both adapters now.cargo test --workspace: 281 passed, 0 failed, 4 ignored ata5ba4a4(two testers report the same count; 280 was the head before it).cargo clippy --workspace --all-targets: nothing new.cargo xtask policy: ok.AI-assisted; no game assets were used.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by SpaghettiMaster545 on 2026-11-24T02:34:03Z.
Update: the head is now
fabe8bc, which adds only test validation insplit_tests.rs; the translator is the same as in5cc9a7e, so the title measurement below applies to it too.Test report with the title itself on a 32-lane host, which the earlier reports did not cover. This PR's head
5cc9a7e(with #223 and #233 under it) againstmaind2a4bae.Tested
cargo test --workspace --no-fail-faston5cc9a7e(debug): 280 passed, 0 failed, 4 ignored.build unknown (b99f876b…)as in #5), diag build (--profile diag --features diagnostics) of each commit, each with its own emptyVICTORY_CACHE_DIR, the sameVICTORY_KEYS(Enter every 3 s from 8 s to 47 s: through the first-boot screens into story mode, which opens at 24 s in both runs), until the host GPU failure:maind2a4bae5cc9a7emain, 26 translate and run with this PR, 90 now stop in translation with a reason (console wave64 lanes on a host without 64-lane waves: 67,a wave64 group sharing LDS without barriers on a host without 64-lane waves: 38, counted over all programs), and 3 were not reached in this run. The 97 programs that translate only onmainare 90 of those driver-refused ones, plus 7 not reached onmain. So nothing that ran onmainstops running here, and 26 compute programs run that did not.Not tested
VICTORY_ADAPTER, a release build of the PR.AI use
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T02:56:39Z.
Thank you for running the title, and for the per-program comparison: "nothing that ran on
mainstops, 26 run that did not" is exactly what I could not check.Two things changed since
5cc9a7ethat touch your numbers:a5ba4a4, rebased onto a fix in #233 (3098672): a program with DPP ords_swizzleand av_readfirstlaneis no longer split in halves, because the upper half read lane 32 where the console reads the wave's first lane (found with a hand-assembled case, wrong on an RTX 5070 before). Such programs now take the console flow if their group is at most 64 threads without LDS, and stop with the reason otherwise. So some of the 26 may move; if you rerun, the new count would tell how common that is.Next, from your counts and that one: the programs that stop with
a wave64 group sharing LDS without barriers(38 in your run) are all groups of one console wave, which the console flow can take with a group barrier before each LDS access. I am working on that as a follow-up on top of this PR, together with more specific reasons for the other 67, so a rerun shows what stops them.The unchanged device removal is what I would expect: nothing in this stack touches #71.
No game data used on my side. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by SpaghettiMaster545 on 2026-11-24T03:03:12Z.
Rerun on
a5ba4a4, the same way as before (diag build onmaind2a4bae, its own empty cache, the sameVICTORY_KEYS, RTX 5070 Ti, driver 621.24):main(the samemainrun as in my first report): of the 119 compute programs the driver refused there, 26 translate and run, 90 stop in translation, and 3 were not reached. 0 programs that ran onmainstop. This is the same split as on5cc9a7e.5cc9a7e, program by program: 0 lost and 0 gained. So thev_readfirstlanechange in3098672moved none of the 26 that this run reaches: they either have no DPP /ds_swizzlebeside av_readfirstlane, or they now take the console flow and still run.console wave64 lanes on a host without 64-lane waves53,a wave64 group sharing LDS without barriers on a host without 64-lane waves37. The 37 are the ones your LDS follow-up would take; I can rerun that when it is up.5cc9a7e. The difference is in programs only one of the two runs reached (the runs end at the hang, at 92 s and 115 s), not in programs that changed outcome.cargo testnot rerun ona5ba4a4: the new commits since my run change the split's selection and its tests, and the title result above is what they affect.(Claude Code, Claude Opus 5.5: ran the build and the title, compared the two logs program by program.)
Imported from Marvisak/VIctory. Originally posted by MisaXz on 2026-11-24T02:25:02Z.
Test report for
5cc9a7eon a second machine with a 32-lane and a 64-lane adapter (following up on the #233 thread).Tested
5cc9a7e(based2a4bae):cargo test --workspace --no-fail-fast: 280 passed, 0 failed, 4 ignored.cargo test -p victory-shader --lib -- split_tests lane_read_loop --nocapture --test-threads=1: every case printsexacton both adapters, the RTX 5080 withsplit trueand the Radeon withsplit false. That includes:lane_reads_in_a_loop_lanes_leave_at_different_iterations(the #225 repro): wave32 and wave64 exact on bothloops_with_an_exit_mask_grown_from_zero(the new test for the untracked-mask join): exact on bothlane_writes_reach_lanes_outside_the_branch,loops_run_while_any_lane_of_the_console_wave_does,masks_read_whole_count_both_halves(64, 48 and 32 threads),lane_reads_cross_halves,dpp_row_masks_name_console_rows,in_half_lane_reads_match_the_console_on_every_adapter(32, 64, 128 threads), the 3-D groupsNot tested
Re-run on the new head
a5ba4a4(same machine, both adapters):cargo test --workspace --no-fail-fast: 281 passed, 0 failed, 4 ignored.cargo test -p victory-shader --lib -- split_tests lane_read_loop --nocapture --test-threads=1: 12 passed, every case printsexacton the RTX 5080 (split) and on the AMD Radeon(TM) Graphics iGPU (native).AI use
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T03:25:21Z.
The follow-up I mentioned is up as #439 (head
88cb024, on top of #320): programs of one console wave per group that share LDS now take the console flow on 32-lane hosts, with a group barrier before each LDS access, and what still stops says why (a group of more than 64 threads,ds_permute across the halves,a whole-wave section).If you rerun, the numbers that would tell the most are the count per reason on
88cb024and, for the whole-title run, whether the validator accepts every emitted compute module. I could only check hand-assembled programs: they validate and are exact on an RTX 5070 and a Radeon iGPU, and I say in the PR that the LDS tests there do not prove the barrier is needed.No game data used on my side. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by miniongk on 2026-11-24T03:33:39Z.
Tested
a5ba4a4on an RTX 5080, driver 621.24, Windows 11 26300, with a local Xbox Series 1.0.2.1 copy.cargo test --workspace: 281 passed, 0 failed, 4 ignored. The single lane-read/divergent-loop synthetic case also passed on its own in 0.53 s.On the real title path, this removed the host-pipeline refusals seen on
mainand the divergent cross-lane translation failures seen with #189. The run still ended inDXGI_ERROR_DEVICE_HUNG; DRED implicated mesh dispatch and indirect-execution commands. So this is a useful shader improvement, but does not by itself resolve #97 here.Only aggregate counts and error classes shared, no game data or raw game logs. AI-assisted (Kimi Code).
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T03:40:33Z.
@miniongk thank you for the run on the title. Two counts would make it usable as evidence, if you still have the logs:
mainrefused in that run and how many this head refuses (host pipeline refusedlines), anda cross-lane read in divergent control flowand how many of those translate here.Also, if you can run
victory translate --validateover the same files: a whole-title run found 20 modules this head emits that the validator refuses, which is why this PR is a draft, and a title run does not show them. #439's head9745f35prints what each refused module declares and calls.Counts and messages only, please. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by EduAzevedo on 2026-11-24T03:58:26Z.
Corpus-wide numbers for what was seen on one shader above:
077ec8b, retail shaders (v1.0.2.1), offlinevictory translate --listagainstmaind2a4bae, all 26,148 programs.a descriptor neither loaded nor built: 298 → 3.a descriptor read from the first lane of a phi, so only one more program translates on this branch alone.mainstops translating.So nearly all of what this PR unlocks goes through that phi case, which matches the #320 combination results above.
AI-assisted.
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T04:00:48Z.
@EduAzevedo thank you. I think this was meant for #307:
077ec8bis that PR's head, and the two things it refers to ("seen on one shader above", "the #320 combination results above") are comments on its thread, not this one. It is worth reposting there so @AntoninMichelq sees it, since "294 of the 298 now stop ata descriptor read from the first lane of a phi" tells them what to do next. Nothing in this PR touches descriptor tracing.For whoever merges #307 and this PR together, since that combination was tested: I checked the merge of
077ec8bwith this head. There is one textual conflict, inemit/lower.rs: both add av_readfirstlane_b32arm at the same place, #307 for a waterfall loop's recorded reads and this PR for the console flow. Keep both, #307's first, as that tester did: its guard is the more specific one, and a waterfall read should stay the lane's own dword in the console flow too. #307's test helper also needs the fields #233 adds tolower::Parts(target,console_cf, andper_lane_onlywith this PR). I will do that on my side if #307 lands first.From reading the merge only; I did not build or run the combination. No game data used. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by EduAzevedo on 2026-11-24T04:03:10Z.
Im sorry, getting a little crazy here 😂
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T05:55:01Z.
Housekeeping, so the thread and the description agree:
image_sampleclass thatmainhas too and #180 fixes, as the note at the top of the description says.mainemits 23 modules of that class, not 22 (22 is #233's count, per the tester's table); three commits are new here, not two; the test count ata5ba4a4is 281, as @MisaXz and @miniongk reported, not 280.mainwith nothing regressing.Head unchanged (
a5ba4a4). AI-assisted (Claude Code).Imported from Marvisak/VIctory. Originally posted by AKA0GHOST on 2026-11-24T07:52:24Z.
Tested this PR on an RTX 5070 (Blackwell, 32..32, driver 621.14), and extended the console flow to LDS. Diff below in case it is useful.
Why: on Grand Theft Auto VI the screen-size lighting compute passes (160x90 / 320x180 dispatches) are dropped on NVIDIA, which leaves every full-screen HDR/lighting target at 0. Six of them still fail with this PR. All six are 8x8x1 = 64 threads, one console wave. What keeps them out of the console flow: 3 use only LDS (128 dwords, no
s_barrier), 1 uses LDS + whole-wave sections, 2 use sections (+v_permlanex16).Change: allow LDS in the console flow for one-wave groups, with a group barrier after each LDS access. In the console flow both halves run the same instruction stream and every thread reaches every block, so a barrier after op n gives the console's in-wave lockstep order for LDS. It can't hang, for the same reason the exchanges can't.
Test (
split_tests.rs, hand-assembled): lane t writes3tto LDS dword t, then reads dword63 − twith no barrier, then addsv_readlane(v0, 40)to force the console flow. It expects3(63 − t) + 40. Exact on the RTX 5070, and all 11 split tests pass.In game: the 3 LDS-only passes (
0e366d15868e17bd,5e7cd6d3557a6c35,a14c1da4be7b9837) now emit, validate and run. A 480x270 RGBA16F target now holds a lit sky/horizon, and several 256x256 RGBA16F targets fill. The full-screen lighting targets are still 0. The remaining blockers are whole-wave sections in the console flow (the halves would exchange partial results throughexchange()) andv_permlanex16(#98).Not done: the full test suite with this change; only the split tests ran.
AI-assisted (Claude Code); no game files attached.
Imported from Marvisak/VIctory. Originally posted by AKA0GHOST on 2026-11-24T07:58:23Z.
Follow-up to my comment above: I missed that #439, stacked on this PR, already does the LDS part (a barrier before each access, same effect as the one after in my diff). It also covers whole-wave sections across the halves, which my diff doesn't. Please disregard the diff here.
Checked #439 + #20 on the same RTX 5070 with the same seven lighting shaders from Grand Theft Auto VI: six now emit, validate and get pipelines (
0e366d15868e17bd,2f03a2df10503cef,5e7cd6d3557a6c35,a14c1da4be7b9837,bfad8c6743ac5977,3d002bca51069e01). Onlya929109552ce1e84still stops (v_permlanex16, #98). I'll put in-game results on #439.AI-assisted (Claude Code); no game files attached.
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T08:35:48Z.
@AKA0GHOST thank you, and no harm done with the diff: arriving at the same barrier independently is a useful check on the idea. Your finding is the more valuable part: that the screen-size lighting passes are among the programs dropped on NVIDIA, and that six of the seven emit, validate and get pipelines with #439 (+ #20) on an RTX 5070. That is the first report tying this stack to specific passes whose output is missing. In-game results on #439 would be very welcome, with one caution from other runs: the world needs the PR set from #71 (and
VICTORY_SHADER_LOOP_LIMIT=32on some cards) to stay up long enough to look.The seventh (
a929109552ce1e84,v_permlanex16) is outside whole-wave sections, I take it; inside a section the stack follows it, outside it nothing here lowers it, and #98 is the PR for that.Rebased onto
main2e4e280, force-pushed with lease: head is4a38a75, wasa5ba4a4. Upstream merged 32 PRs and two of their new tests needed the argument #223 adds (fixed there). The three commits of this PR are replayed unchanged and each builds on its own; the description gives their old ids.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T08:44:06Z.
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate --pipelines(pipelines created on an AMD RX 9070, Adrenalin, Windows 11; dxil.dll from SDK 10.0.26100), against main1f858b0. Counts are emitted / validated / pipelines.These were run on the RX 9070 (64-lane host), so the console-flow paths for 32-lane hosts are not what is measured here.
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T11:02:31Z.
@slint6614-dev, the RX 9070 results give us a wave64 comparison for the RTX measurements. On #320, 22 more compute programs emit and two more validate. The increase of 20 stage-validation failures matches the class tracked in #201. The RTX opcode census on #233 found
samplein every failing module. Confirming that diagnosis for the AMD set would require matching the modules or inspecting their emitted ops. #180 covers the implicit-derivative compute lowering.AI-assisted (Codex).
Imported from Marvisak/VIctory. Originally posted by AKA0GHOST on 2026-11-24T15:55:42Z.
@r4tedx thanks. On the seventh (
a929109552ce1e84, 8x8x1, no LDS): its threev_permlanex16_b32are all inside whole-wave sections. Each follows ans_or_saveexec_b64 s[4:5], -1, and EXEC is restored froms[4:5]after it (DPP row ops alongside). Still, #439 at the head I built (055aef9, + #20 + main56d5032) stops it withemit: v_permlanex16_b32. So it seems the section simulation doesn't cover this shape; I didn't dig into why.The in-game results on #439 are still pending. My runs so far hung before reaching a world frame in the capture window, so I'll post once I have one, with the #71 PR set as you suggest.
AI-assisted (Claude Code); no game files attached.
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T15:57:44Z.
@AKA0GHOST, thank you, that is the detail I was missing. Checked here offline (local title data, CPU only):
a929109552ce1e84stops at the same instruction (offset0xd00) withemit: v_permlanex16_b32onmainffe310e, and on #439bf0f951for a 32-lane host and for a 32-64 host alike. So it is not something this stack takes away or the wave split causes: the instruction has no lowering of its own anywhere yet, and the whole-wave section recogniser (emit::wave) followsv_permlanex16only in the shapes it knows. Your description (each one afters_or_saveexec_b64 s[4:5], -1, EXEC restored froms[4:5], DPP row operations alongside) says this is a section shape the simulation does not follow, which fits the reason it falls through to.Two ways to take it, both after this PR and #439 (they stay as they are for review): teach the section simulation this shape, or lower
v_permlanex16_b32on its own as an in-half read (each lane takes a lane of the other row of 16 in its 32-lane half), which also covers the instruction outside sections. @MichaelSmithAI's port of #404 on #439 does the second for the all-active form, with a test in both the split and the console flow; I will look at that first.For the in-game runs: a hang before a world frame on a 32-lane card is most often the wave64 mesh programs (#71, #778), not compute, so the #71 set is the right one to add.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by LooperSalty on 2026-11-24T16:37:39Z.
From a tester working with Claude (AI-assisted); measured on my own machine (i7-13700KF, RTX 4070 Super). No game data involved.
Data point for the divergent-flow cross-lane work: we also handle the wave prefix (
v_mbcntallocation, ballot-count plus prefix) in a divergent flow on a 32-lane host, each 32-lane half of the console's 64-lane wave computed independently (half-wave sum, election, atomic, readfirstlane, prefix), under an opt-inapproxmode. A test builds the allocation per half and checks the halves get disjoint ranges (it fails if the halves are merged).Measured: the four InstanceCulling_CS_{Prop,Tree}_* programs get past the prefix; with a stride table for bindless heaps (#704) they emit, validate with dxil.dll and create their PSO on the RTX 4070 Super. Without that table they stop at "unknown stride".
It sits on top of the Wave64-on-Wave32 stack (#189/#439/#320 and our own cross-lane option), which is not on main, so I am not publishing a branch; I can post the diff of the prefix part here if it helps.
Imported from Marvisak/VIctory. Originally posted by 465d6a0eac on 2026-11-24T17:02:38Z.
Thank you for this, @r4tedx! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/34. It went in together with #439, which builds on it. You're credited as the author there. This pull request stays the original.
Test results
cargo clippy(both variants) andcargo test --workspacepass (407 passed, 0 failed).victory translateover the 26,148 shader programs in my own copy of the game with--host-lanes 32-32, before → after #320/#439: compute programs emitted 1,221 → 1,422 of 2,582; "a select on an untracked mask" 284 → 0, "a lane mask holding lanes elsewhere read as data" 266 → 3, "console wave64 lanes on a host without 64-lane waves" 162 → 0.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:27:10Z.
Automated triage for the maintainers.
Needs work: needs the maintainer's decision. The clippy error named in the last triage is fixed: head
960b3e1passesemit::Target::ANYinplaced_uav_tests.rs(merged up from #223), and CIcheckpasses. Nothing else changed since85362ac.The verdict stays because this PR's own part (the console flow for compute programs with
v_readlane/v_writelaneand a divergent branch, with the per-lane fallback, and SGPR spills kept per-lane sinced5f8f2c) can only land on top of #223 and #233. #233 is waiting on a maintainer's choice between this stack and #2176/#2925. The evidence is the right kind: lane readbacks on 32-lane hardware (16 of 16 on an RTX 3070 ateb12838) and title translate counts with no program lost. Once #233 is decided, this needs a maintainer read in stack order.CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-25T07:08:54Z.
Updated for the needs-rebase triage:
main(940d32f) is merged in through #233, headeb12838(merge commits, no rebase). It carries #233's three fixes (see there). Conflicts were inlower.rs,mod.rs,structure.rsand the test files:emitkeeps the per-lane fallback when the console flow cannot lower a program that asked for it only for correctness; this PR'sStructured::othersbecomesmain's identicalStructured::other.One behaviour to know about: compute programs that spill SGPRs through
v_writelane/v_readlaneand have a divergent branch now take the console flow on every host by this PR's rule, althoughmain's spill handling already makes the per-lane form exact for them; the per-lane fallback stays. On a host that runs the program's wave size that adds no barriers (one host wave is the console wave).Checks: both CI clippy commands clean;
victory-shader270 passed, 0 failed, 3 ignored, on an AMD Radeon iGPU only. Not run on a 32-lane card today (see #233).AI-assisted (Claude Code).
upstream-sync referenced this pull request2026-11-25 08:06:36 +00:00
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-25T10:55:04Z.
Pushed
d5f8f2cefor the triage note on SGPR spills: spillv_readlane/v_writelanekeep main's per-lane form, with the console's wave size where the host runs it and none on a 32..32 host (each restore lowered as its SGPR). New testsgpr_spills_across_a_divergent_branch_stay_per_lanechecks the wave size on both targets (64 onTarget::ANY, none on 32..32) and that the first pass without the console flow gives the same DXIL; it fails with thelower.rschange reverted. Description updated.Verified locally: clippy
-D warningsclean (default and--all-features);victory-shader --libon WARP, one test thread: 269 passed, 2 failed, 3 ignored, the 2 being the known hardware-only checksgathers_at_a_level_match_the_hardwareandpermutes_read_the_lane_named_and_zero_from_lanes_left_out. No hardware adapter and no title data used.AI-assisted
upstream-sync referenced this pull request2026-11-25 12:03:46 +00:00
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-26T05:07:45Z.
Merged current
main(63bcca4) in, with no rebase or force-push. Head nowdb85706, and it merges cleanly withmain. The PRs above (#439) are merged from this head in turn. Details, conflict notes and the per-level checks are on #439 (policy ok, clippy clean, the WARP shader suite has onlymain's own 4 failures).Synthetic tests only; no title data used.
AI-assisted
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-26T05:14:09Z.
Correction to my last comment: CI's clippy failed on the previous head. Main's view-mark draw test (
crates/victory-gpu/src/draw.rs) buildsemit::Options { view_marks: true }by hand, and this stack adds atargetfield toOptions. My local clippy run left out the test targets, so I missed it. New head85362acehas the fix merged up from #233: the test fills the remaining fields with..Options::default(). Nothing else changed.Verified on #223
0f6dec04and #4398a320556:cargo clippy --workspace --all-targets --locked -- -D warningsis clean, andcargo xtask policypasses. No title data was used.AI-assisted
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-26T05:18:49Z.
Second follow-up: CI's diagnostics clippy (
--all-features) found one more call from main that this stack'sTargetargument breaks. Incrates/victory-gpu/src/pipeline/placed_uav_tests.rs:77,emit::emitwas called with six arguments. New head960b3e19has the fix merged up from #233: the call passesemit::Target::ANY, the same default the other callers use.Verified on #223
fbfd3c67and #43913be4c2c: both CI clippy commands are clean,cargo clippy --workspace --all-targets --locked -- -D warningsand the same command with--all-features. I didn't run the CIcargo test --workspacestep on this PC, so CI will be the first to run it on this head. No title data was used.AI-assisted
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-26T05:23:05Z.
This triage reviewed
85362ace. Theplaced_uav_tests.rs:77call it names is fixed on the current head960b3e19: the call passesemit::Target::ANY, and it came up from #223fbfd3c67. CI now passes on all four heads of the stack: #223fbfd3c67, #23387d1f423, #320960b3e19and #43913be4c2c. Merge order is unchanged: #223, then #233, #320, #439.AI-assisted
Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-26T18:38:45Z.
Wave64 hardware check of
960b3e1.Checked against a hardware table measured on an AMD Radeon iGPU (gfx1036, RDNA 2, Ryzen 7 9800X3D) in native
wave64: 64 cross-lane instructions x 8 EXEC masks (all, lo32, hi32, all but lane 0, alternate lanes, lane 40 alone,
lanes 31+32, a sparse mask). Each case was assembled with the same assembler, run through VIctory as a wave64
compute program of 64 threads on the same Radeon through D3D12 (WaveSize 64, dxil.dll validated), and all 64
lanes compared with the hardware. EXEC is narrowed two ways: straight-line (
v_cmpx_ne_u32, lowered with a laneguard) and branched (
s_and_saveexec_b64+s_cbranch_execz, a DXILif). Windows 11, Rust pinned, debug.No game files were used.
Tested (merged onto main
63bcca4; the harness goes through the same console-flow retry asemit_with):v_readlane_b32at lanes 0/31/32/40/63 40 of 40 exact (main: 18 wrong,e.g. lane 63 read under lo32 gives 0 instead of 0x40) and
v_writelane_b3224 of 24 (main: 14 wrong).Straight-line form unchanged from main (#2830 / #1312 cover those cases).
readfirstlane, writelane, v_mbcnt, compares, swizzle, DPP). ds_bpermute/ds_permute are refused there
(
console wave64 lanes on a host without 64-lane waves).Not tested: the title, cost per lane.
AI use: Claude Code (Claude Opus 5.5) built the harness and the hardware table, ran them on the GPUs named here and wrote this report; the numbers come from those runs.
Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-27T00:46:14Z.
Wave64 hardware check of
960b3e1on a 32-lane host (RTX 5080): 151 more cases, inside branches and loops. This follows my table check above.Setup. Windows 11, an RTX 5080 (32..32) and the Radeon iGPU of a Ryzen 7 9800X3D (gfx1036, RDNA 2) in one machine. 151 hand-written GFX10 wave64 compute programs (our own code, one 64-thread group): 13 kinds of construct (wave reductions in a branch,
v_readfirstlane/v_readlane/v_writelanein a branch, LDS one wave shares, the allocation idiom, nested branches, loops, an early-out, vote and break loops), each under up to 10 EXEC masks. The 15 f32 wave sums are refused here like the integer reductions, so they add nothing. Expected values: the same code run natively in wave64 on the gfx1036; an independent Python model agrees with the hardware on every case. Each program goes throughemitwithTarget { lanes_min: 32, lanes_max: 32 },dxil.dllvalidation and a D3D12 dispatch; every output of every lane is compared.Results on the 5080 (exact / differ / refused):
v_readlanein a branchv_writelanein a branch (lanes 0, 33, 63; target lane outside the branch in 8)v_readfirstlanein a branch (its only lane operation)s_cbranch_vccz) aloneThe same translations dispatched on the Radeon give the same counts.
What it means.
v_writelaneignores EXEC on the console, and here it skips the guard (lower.rsguard).console wave64 lanes on a host without 64-lane waves, 78) and LDS one wave shares (a wave64 group sharing LDS without barriers ..., 20). #439 on top translates all 98, and all 98 are exact.v_readfirstlane(no console lanes, so no wave size, and it runs per host wave; mask all: lane 32 reads 0x65 instead of lane 0's 0x5). 3 are a vote loop with no lane operation, which runs per lane. I proposed a change for the first-lane case on #439.Not tested: the title; cost per dispatch.
AI use: Claude Code (Claude Opus 5.5) wrote the cases, the harness and this report, and ran them on the GPUs named here; the numbers come from those runs.
Float wave sums on the same branch
Setup. Hand-written console wave64 compute programs, one 64-thread group each, translated by this branch's
emitwithTarget { lanes_min: 32, lanes_max: 32 }(what an RTX 5080 reports), for the RTX 5080. The cases are 34 whole-wave f32 sums and 20 f64 sums in the compiler'sWaveActiveSumshape (DPP8 x3,row_mirror bound_ctrl:1,v_permlanex16_b32,v_readlane_b3232 / 0), inside per-lane branches or after an early-out. The reference is the gfx1036 iGPU of the same PC, running them in wave64.Every case is refused with
GFX10 code at 0x0: console wave64 lanes on a host without 64-lane waves.Meaning. On its own, #320 does not take a wave64 whole-wave sum on a 32-lane host, so these cases cannot test the order of its additions. #439, which builds on it, takes the f32 ones: 20 exact and 14 differ on the 5080, all 14 in
WaveActiveSum's order (see my note there).AI use: Claude Code (Claude Opus 5.5) wrote the cases and the harness and ran them on this PC. The numbers come from those runs.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.