Repository navigation
Conversation
…iers The console runs s_barrier per wave: a branch skips a block only when no lane of the wave needs it, and otherwise the wave runs the block, barrier included, with the other lanes masked off. On the host each lane takes its own branch, so lanes skipping such a block never arrive at its barriers and the group's other lanes wait for them forever: a GPU hang. The title's compute_graph_ops matrix programs (6 barriers on one side of a per-lane branch), sky_scattering CS_MultipleScattering (7), and its blendshape and density-shadow programs (1 each) were all in hung submissions. A host barrier counts arrivals, not instructions, so at each per-lane branch the lighter side's edge now gets as many barriers as the two sides' counts to the program's end differ. Counts are taken over forward edges as the sets possible along uniform paths; a branch leaving or going round a loop without barriers needs none. 55 programs get extra barriers; all 1,951 emitted compute programs still validate. Not countable, and emitted unbalanced as before (refused, they would not run at all): a loop with a barrier left per lane, counts that differ along uniform paths inside a per-lane branch, and indirect jumps. 33 of the title's programs, among them compute_graph_ops CS_FormulaOperation, the luminance histograms and the shadow classification, can still hang. shortcut: the extra barriers are at the start of the lighter edge, so a lane there may read LDS after the join before the heavier side's last writes before it show. Run in the game on an RTX 2080 since: in the builds here that reached gameplay through the opening cutscene (with the title's pools made larger), and in those loading a save straight into the world. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
… balanced The title's meshlet culling (CS_BatchCullPreSkinnedMeshlets, which runs since the culling ports) sends lanes with nothing left to do straight to the program's end while the others run a section whose barrier count depends on a uniform choice; no fixed count balances that, so the program fell back to unbalanced, and it was in the submission of the last device hang (debug layer: TDR). A side that meets no more barriers on any path runs to its end and exits, and a host barrier does not wait for threads that have exited, so such a branch needs nothing added. shortcut: D3D12 leaves a barrier after a thread's exit undefined; NVIDIA and AMD count exited threads out (an early return before a barrier works there). Unbalanced programs 37 -> 28; the culling's base and _Prev variants are balanced, its ParaboloidShadows ones are not yet. All programs emit and validate as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
…riers run as the console runs them A per-lane branch leaving (or going round) a loop that holds a group barrier is decided for the whole wave, as the console decides s_cbranch_vccz/execz and their nz forms, where that only makes lanes leave sooner (compute_graph_ops CS_FormulaOperation looped until any lane reached its own count, and lanes that left first held the others at its barrier). A program whose barriers still cannot be balanced by counting (53 of the title's) runs in console mode: every branch on a lane mask decided for the wave, every vector instruction guarded by its own EXEC, so lanes reach each barrier together. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
With it, lower.rs would pass the asset policy's 512 KiB limit for a file. Moved as is: the barriers a block holds, loops holding them, branches decided for the wave, the balance and console mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
fuzeofficlal
left a comment
There was a problem hiding this comment.
Verified head 5d7e5e0c cleanly on origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + Windows SDK 10.0.26100.0 dxil.dll).
Findings
emit/lower.rssize headroom (98 Bbelow 512 KiB cap):crates/victory-shader/src/emit/lower.rsgrows from520,563 Bto524,190 B— only 98 bytes belowcargo xtask policy's524,288 Blimit. Any small concurrent change tolower.rswill trip policy unless a bit more helper logic is moved intoemit/lower/barriers.rs.- Edge selection bug in
barriers.rs::leaves_loopon barrier-free loop latches:leaves_loopcomputes(ti, ni) = (inside(r, taken) && !back(b, taken), inside(r, not_taken) && !back(b, not_taken)). Whenbis the latch of a barrier-free loop whosetakenedge is the back-edge andnot_takenexits the loop, bothtiandniarefalse, soif ti { not_taken } else { taken }selectstaken(the back-edge) instead of the exit edgenot_taken.after(taken)then seesback(b, taken)and returns[0], losing all barrier counts after that loop. - Minor observations:
- No unit tests are added yet for
wave_loop_exits,barrier_balance, orconsole_mode. s_cbranch_scc0/1followings_cmp_eq_u64/s_cmp_lg_u64(whichstructure.rsmodels per-lane as!(a ^ c)) would maps_cbranch_scc1towaveAnyTruerather than all-lanes-equal inwave_loop_exits/console_branches.
- No unit tests are added yet for
Architecture & Local Verification
- The three-tier approach (
wave_loop_exits->barrier_balanceedge-block padding ->console_modest.whens+st.execsfallback) preservesgroup_barrier's UAV fence (1 | 2 | 8) and meshno_barrierhandling cleanly. cargo test --locked -p victory-shader --lib -- emit::flow_tests emit::lower:: emit::crosslane_tests(RTX 5090 + WARP +dxil.dll): 39/39 passed.cargo clippy --locked -p victory-shader --tests -- -D warnings(default and--all-features) &cargo xtask policy(192 files ok): clean.
kotekompotek
left a comment
There was a problem hiding this comment.
Scoped review: the three-tier design is the honest shape for this — wave-uniform loop exits first, balanced extra barriers where counting permits, and console_mode (whole-wave branch + EXEC guards) as the fallback when balance can't be proven. The named real-world programs (luminance histograms, shadow classification) give it a testable target list. The invariants are subtle — a barrier on an edge must be provably unreachable by lanes that didn't take the branch — so this one deserves a maintainer eye on barrier_balance's counting, which I did not fully trace.
|
Automated triage for the maintainers. Needs work. The new commit
CI still fails on this head, with the same failure as before. CI: failing. Generated by Claude Code |
…dware adapter and WARP Review of Marvisak#2920: - leaves_loop took a loop latch's back edge as the side leaving a loop without barriers (and the back edge of a branch going round), whose count is 0 over forward edges, losing every barrier after the loop. It takes the forward side now: the other side of a back edge, else the side leaving the loop. - SCC of `s_cmp_eq` of two masks is set when all lanes are equal, not when any lane has the condition: such a branch is decided the other way round for the wave (Lower::wave_test, shared by the loop exits and console mode). - The comments describe the patterns instead of naming programs. - The wave-wide branch's lowering moves to lower/barriers.rs: lower.rs is 522,167 bytes, 2 KiB under the asset policy's limit. barrier_tests: one group of 64 threads in two waves of 32, hand-written GFX10 checked against the decoder, each run on the hardware adapter and WARP, which must complete and store what the console would: a barrier on one side of a per-lane branch (balanced), a loop with a barrier left per lane (its exit decided for the wave), a side meeting no more barriers (it exits, which D3D12 leaves undefined) and the same with a barrier after the join (console mode). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
… own exit A loop whose exit console mode decides for the wave keeps lanes that would have left going round with the others; on the console EXEC leaves them out of the rest of the loop. Here their vector instructions still ran, guarded only by the EXEC the structure works out per instruction, which cannot say that a lane left in an earlier round: a counter in the loop counted every lane to the wave's last round (barrier_tests, the loop left per lane, stored 4 for every thread). At every loop header a phi says whether a lane is parked, false on entry. A latch whose other side leaves the loop parks the lanes that would have left while the wave goes round, and every instruction in the loop is guarded by !parked too. Only in console mode. shortcut: only at a latch (the do-while shape); a branch going round from the middle of a loop keeps its lanes running to the latch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
…ails without it - a_loop_ended_by_a_mask_compare_goes_round_while_any_lane_is_left (on the hardware adapter and WARP): a loop with a barrier going round while `s_cmp_eq_u32 exec_lo, 0` is clear. Without the flip of an equality of masks, the wave left after its first lane. - a_loop_without_barriers_pads_the_side_that_skips_it (lowering only): the side holding a loop without barriers, then a barrier, is the heavier one. Counted by the latch's back edge, it looked lighter and was padded instead (the edge into `v_and_b32` rather than `s_or_b32`). NVIDIA's results do not show that, so the lowering's added barriers (Lowered::extra_barriers, in tests) are checked. - a_loop_without_barriers_counts_the_barriers_after_it runs the same program on the GPU, with LDS written before the side's barrier and read after the join (cleared first: LDS keeps what a dispatch left). The test programs get 512 bytes of LDS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
|
Thanks for the reviews, @fuzeofficlal and @kotekompotek, and for the triage. Pushed as Tests (
Fixes.
On the early exit: if the hardware and WARP runs ever disagree here, the fallback is to send such programs to console mode instead (they'd cost guards but not rely on undefined behaviour). It's a one-line change in |
…and only in loops that park Three corrections to the parked lanes (dd15e11): - The guard and the latch test use the loop's natural body (the header and the blocks reaching a latch without passing it) instead of an RPO range, which could hold blocks beside the loop that the header's phi does not dominate. - Parked lanes take no part in the wave's exit test: on the console EXEC leaves them out, and their frozen registers could keep saying "go on". For any lane only unparked ones count; for all lanes parked ones agree. - Only loops with a latch that parks (its exit decided for the wave, the other side leaving the loop) get the phi and the guards; every other loop is lowered as before. victory-shader on an RTX 2080: 306 passed, 4 failed (the same 4 as main on this card); the 8 barrier tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
The problem
The console runs
s_barrierper wave. A branch skips a block only when no lane of the wave needs it; otherwise the wave runs the block, barrier included, with the other lanes masked off. The host'sGroupMemoryBarrierWithGroupSynccounts threads: each lane takes its own branch, so lanes that skip a block holding a barrier never arrive there, and the rest of the group waits for them forever. That's a GPU hang (TDR).The title's compute programs where this hung submissions here:
compute_graph_ops: the matrix programs (6 barriers on one side of a per-lane branch), andCS_FormulaOperation, which loops until any lane reaches its own count.sky_scattering CS_MultipleScattering: 7 barriers.CS_BatchCullPreSkinnedMeshlets: the meshlet culling, in the submission of a device hang (the debug layer reported the TDR).What this does
9eadbf3).0e0b272).8de7c96).s_cbranch_vccz/execzand theirnzforms, where that only makes lanes leave sooner.5d7e5e0moves this code as is intolower/barriers.rs. With it,lower.rswould pass the asset policy's 512 KiB per-file limit.lower.rsis now 524,190 bytes, close to the limit, so the next large addition will need a split too.Numbers
Measured on the earlier upstream base the commits were first written on, not re-measured on
63bcca4:_Prevvariants are balanced; its ParaboloidShadows ones aren't yet.Tested
cargo clippy -p victory-shader --all-targets -- -D warningsis clean, andcargo xtask policypasses.cargo test -p victory-shader --libon an RTX 2080 (Windows 10, with Tests: the GPU tests load the D3D12 Agility SDK, as victory.exe does #2878's test exports so the hardware device runs): 298 passed, 4 failed. All four fail the same way on plainmainon this card, none through these commits:a_heap_buffer_read_by_element_takes_the_views_stride: NVIDIA's structured views, GPU: on NVIDIA, structured buffer views are made raw #2464.a_heap_buffer_read_where_no_buffer_view_is_reads_zeros: NVIDIA's view-heap cap, GPU and shaders: a host that caps its view heaps gets heaps at its ca… #2461.pops_wait_loop_exits_immediately_for_inactive_lanes: wants a shader model 6.6 WARP device, and Windows 10's is 6.2.gathers_at_a_level_match_the_hardware: another texel on NVIDIA. It failed on plainmainhere too, and passed in one run.In the game, on an RTX 2080 (32-lane waves), Windows 10 19045: these commits have been in the builds here that reached gameplay through the opening cutscene (with the title's pools made larger, #698), and in those loading a save straight into the world, together with #2460 #2461 #2462 #2464.
No unit tests are added. The cases above are the title's programs, and I'd welcome a pointer to the preferred place for synthetic barrier cases.
Also builds on this: the wave64 split (#1960) and a console mode for a group of one console wave split into two host waves (work in progress on my side, for the
InstanceCullingpasses) both use the wave-wide branch decisions.AI-assisted (Claude Code); the runs were on my machine. No game data.
🤖 Generated with Claude Code
https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G