Repository navigation
Conversation
… on divergent s_barrier
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Verified and tested on Windows 11 x64 (D3D12 WARP + Hardware).
- Confirmed mesh output initialization: passes = mesh.max_primitives.div_ceil(threads.max(1)) properly ensures all primitives up to max_primitives are initialized even when threadgroup size is smaller than primitive count.
- Vertex index culling �ad = (x < 0) || (i >= max_vertices) properly prevents out-of-bounds indices from faulting host rasterizers.
- Confirmed divergent control flow barrier analysis via divergent_barriers: stripping SYNC_THREAD_GROUP (bit 0) while retaining memory fences (mode = 8 | (writes_uavs ? 2 : 0)) prevents threadgroup deadlock when warps diverge across conditional exits on 32-lane hosts.
- All 69 �ictory-shader tests pass cleanly ( est result: ok. 69 passed; 0 failed).
- cargo clippy -p victory-shader --lib -- -D warnings clean (0 warnings).
- cargo xtask policy clean (151 files ok).
|
In-game data point for AI-assisted (Claude Code, Claude Opus 5.5); no game data. |
|
RTX 5080 (native Windows 11, driver 621.24): still I tested
Both runs ended in This is one run per build, so the shorter time may be noise. On this card the hang is not fixed, and it still moves between mesh programs, as described in #71. |
|
The mesh bounds guards and multi-pass
Static code review only; AI-assisted. |
catminou4
left a comment
There was a problem hiding this comment.
Test-merge with current main (ffe310e) is clean; cargo test -p victory-shader --locked → 96 passed / 0 failed / 1 ignored (macOS arm64, rustc 1.98.1). Caveat: all three changes are mesh-shader-only paths, and mesh execution tests are Windows-gated, so the green run only proves no regression on non-mesh lowering — the new logic itself is unverified by anything I can run here.
Static review (looks careful, but needs Windows-side validation):
divergent_barriers: backwards reachability from eachs_barrierblock vs. backwards reachability fromLaneExit::Endblocks without crossing the barrier, then flags the barrier if any non-uniformLaneExit::Branchhas one side reaching it and the other bypassing. Fence-only emission (droppingSYNC_THREAD_GROUPbit 0) for those blocks is the right deadlock avoidance for 32-lane hosts. Two things to confirm on hardware/Windows: (a) a barrier flagged fence-only still orders shared-memory accesses correctly for the lanes that do reach it, and (b) thecan_bypassBFS seeds from ALLEndblocks — including ends inside loops that reconverge before the barrier; if such an end can reach the barrier again, the flag may be over-conservative (safe direction, just slower).- Mesh bounds guards: vertex/primitive exports now AND the existing guard with
flat < max_vertices/max_primitivesonly whenthreads > limit— correct and free when the launch fits.emit_indicesadditionally culls any of the 3 vertex indices>= max_vertices(IUGE) alongside the existing negative check, zeroing all indices viabad— out-of-range indices can no longer fault the rasterizer. The per-passemitIndicesloop insetMeshOutputCounts(div_ceil(max_primitives, threads), guard only on the overflowing pass) matches DXIL's one-primitive-per-call shape.
None of this is testable on macOS — I'd want a Windows mesh-shader smoke (or the existing #[cfg(windows)] valu tests extended with a divergent-barrier case) before this lands.
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 1052a90 on Windows 11, RTX 5070, MSVC: cargo test -p victory-shader -- --test-threads=1 69 passed, and cargo clippy -p victory-shader --all-targets is clean. victory translate --validate --pipelines on the local title executable still reports 12 of 12 programs. That executable has no mesh programs, so the mesh half isn't exercised there. The PR adds no tests of its own.
The mesh bounds guards look right: writes past max_vertices/max_primitives are masked, every primitive slot gets an emitIndices, and indices at or past max_vertices are culled. One concern before approving:
lower.rs(s_barrierwithfence_only_barrier): droppingSYNC_THREAD_GROUPswaps a host deadlock for a silent data race. The console code put a barrier there because later instructions read LDS or UAV data another wave wrote before it. With only the fence bits, a warp can run past the barrier and read stale data, which is far harder to diagnose than a hang. A more honest option is to refuse the program ("a barrier under a per-lane branch") so it shows up intranslatecounts, or to move the barrier to the point after the divergent region where all warps meet. If you keep the fence-only form, please log it once per program atwarnand add a test pinning which blocksdivergent_barriersselects.- A test for the mesh guards with
threads > max_primitiveswould help too. A two-passemitIndicesloop is easy to get off by one.
AI-assisted (Claude Code).
|
On the On the console, The divergence comes from our side. The per-lane form turns EXEC into per-lane branches, and on 32-lane hosts a console wave runs as two host waves. If one half has no lane on the path, it skips the barrier that its console wave reaches. What would keep both, ordering and no hang, is running such programs so that both halves take every branch together: #439's console flow. That works for compute today in groups of up to 64 threads. Mesh shaders can't declare a wave size, which is why I'm prototyping a compute form of mesh programs (#3) that could use it. On #778 I've asked for a census of the title's mesh group sizes to see whether they fit. So +1 to splitting. The bounds and initialization guards have hardware evidence (RX 9060 XT above) and could land on their own. The barrier change would need a test where a lane-dependent AI-assisted (Claude Code); reasoning from the code and the console's ISA semantics, not a title run. |
|
On an RTX 3070 Ti Laptop (wave lanes 32..32, NVIDIA driver 610.88, Windows 11 build 26300) this PR removes the world hang in wave64 mesh programs, without skipping them. Tree:
The opening credits render correctly in the world. The run ended still inside the credits, so I have not seen the scene behind them yet. |
|
Correction to my note above: two longer runs (900 s budget) with the same tree (
My 420 s run had simply not reached them. So #587 does not remove the mesh hangs on the RTX 3070 Ti. It only let the world run longer with the mesh programs enabled (about 1,400–2,000 draws kept per frame) before one of them hangs. Sorry for the noise. |
…imitives, omit sync on divergent s_barrier Resolved the append-at-end conflict in lower.rs with the later lds/gather helpers. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… 32-lane hosts (diagnostics) Test switch for Marvisak#578's refusal: with it a run shows what those programs do on an NVIDIA host once other causes are removed (Marvisak#587 merged: the hang stays, 4.3 s of GPU per frame, device removed; with VICTORY_SHADER_LOOP_LIMIT=64 the same run stays up, 3700 draws per frame at 90 ms of GPU). Diagnostics builds only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… initialised, no group sync at a barrier only some lanes reach) By FibbS6. One textual conflict in emit/lower.rs (its `divergent_barriers` beside Marvisak#453's `interp_mode`; both kept). One change to the PR's behaviour, in `Lower::new`: its fence-only barriers are not applied in the console flow of the wave64 stack (Marvisak#233, Marvisak#320, Marvisak#439). There every lane of a wave runs every block, so the lanes come to a barrier together, and the stack relies on the group sync to order one wave's LDS accesses. Per lane, the PR's rule stands. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Marvisak#587 came without tests. Two, neither needing a GPU: - mesh_primitives_past_the_lanes_are_culled_first (emit/mod.rs): for four pairs of lane count and declared maximum, the module validates and has one `emitIndices` per pass over the maximum plus the export's. - a_barrier_only_some_lanes_reach_is_a_fence_without_the_group_sync (emit/lower.rs): a barrier under a branch on the thread's id is emitted with mode 8 per lane; a barrier every lane reaches keeps mode 9. For them, test builds record the `dx.op` calls of the module a thread finished last (`shader::last_calls`: opcode and constant first argument). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A tester bisected an access violation inside AMD's driver, seconds into the world on an RX 9060 XT, to this tree's merge of Marvisak#483 (7ef2c41). The cause is not known. With VICTORY_HEAP_GUARD=0 the host passes u32::MAX where shaders read their heaps' guard slots, so the same shaders redirect no index: one run with it tells a fault in the shaders' shape from one in reads of the guard slot. The default is unchanged. INTEGRATION.md: update 6 (Marvisak#587 with its tests, the switch, the AMD problem and its workaround, the test run). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tives, and omit sync on divergent s_barrier
…fied together Merges Marvisak#156 Marvisak#162 Marvisak#168 Marvisak#169 Marvisak#368 Marvisak#379 Marvisak#456 Marvisak#587 Marvisak#990 Marvisak#1021 Marvisak#1048 Marvisak#1052 Marvisak#1053 Marvisak#1095 Marvisak#1142 Marvisak#1190 Marvisak#1211 Marvisak#1223 Marvisak#1259 Marvisak#1293 on top of the bundle of Marvisak#1402 (which is on Marvisak#1319, on main ffe310e), each head unchanged. Hunks that conflicted in emit/lower.rs, emit/valu_tests.rs and emit/diff_tests.rs were merged by keeping both sides (additions next to each other); a PR was kept only if cargo clippy -p victory-shader --all-targets -- -D warnings still passed with it. No instruction name is handled in two places. Marvisak#98 is not in this version: an offline measurement on a retail dump showed it loses 31 programs that validate on Marvisak#1402. cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (381 passed, 6 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
Problem
On NVIDIA D3D12, translated mesh shaders and compute shaders can fault or hang when:
s_barrieris emitted inside divergent control flow, which deadlocks on 32-lane NVIDIA warps when not all lanes reach the barrier.Fix
s_barrierinstructions inside divergent control flow and omit the full threadgroup execution sync (keeping memory fence semantics).Verification
cargo xtask policy— passed (151 files ok)cargo clippy -p victory-shader --lib -- -D warnings— 0 warningscargo test -p victory-shader -- --test-threads=1—69 passed, 0 failed