Shaders: CS_CollectTriangles(_Meshlets) on 32-lane hosts (local waves with LDS atomics) #388
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!388
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-388"
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?
@fromrivertothesea on GitHub · 2026-11-27 21:49 UTC · original
fromrivertothesea:pr/meshlets-wave32→main· +105 −16 · 1 files · 2 commits · draftProblem
On NVIDIA (32-lane waves), two of the triangle clip's compute programs stop with
no wave32 lowering for this wave64 program, so their dispatches are dropped:vfx_triangleClip:CS_CollectTriangles(#6832a9da15c2e584)vfx_triangleClip:CS_CollectTriangles_Meshlets(#6b82bc7d22016cb5)Both use groups of 1024 threads and all 32 KiB of LDS themselves. Wave-wide branches with console-wave meetings (
VICTORY_WAVE_WIDE=1) can't take them: the meetings and exchange need 177 dwords past the program's 8192, and a D3D12 group never has more than 8192 (the comment atwith_pair_meetingsalready namesCS_CollectTriangles_Meshletsas not fitting). PR #259's split-wave64 fallback doesn't take them either (WAVE64-SPLIT round 0: wave Some(64)).Why local waves are right for them
Reading the program (
shader-info --disasm), the LDS is only ever shared across the title's owns_barriers. Between them there are only:ds_or_b32,ds_add_u32,ds_max_i32), where order doesn't matter;Its wave operations are the allocation idiom that
with_local_wavesalready handles:s_ff1/s_bcnt1/v_mbcnt, the first lane reserving the wave's count, andv_readfirstlaneof the base. The only difference is that the reservation is on an LDS counter (ds_add_rtn_u32 ... offset:4) instead of a buffer atomic. So each host wave can run as a wave of its own.Change (
emit/lower.rs)wave_localaccepts an LDS atomic of the total's operation (ds_add/min/max/or/and/xor, with or without_rtn) as the reservation, as it does buffer atomics. Its operand is read like a buffer atomic's; its address must still not depend on the wave.LdsOrder, but only for a program whose LDS accesseslds_meetingscan't order without it. Every program that translated before keeps its barriers exactly as they were.tight_lds: with local waves, a one-dimensional group whose own LDS leaves no room reserves neither the exchange dwords (local waves never exchange:exchange_halves, lane reads andscc_someall return or refuse onself.local) norwave_base's counter.thread_idthen uses the flat id's 32-aligned runs, which are the host waves for a 1-D group. 2-D and 3-D groups keep the counter (#1243).Tested
mainand with this branch (translate D:\GTAVI --list,VICTORY_HOST_WAVE=32): only these two differ, both from refused to emitted. Every other program's DXIL hash is identical. (no wave32 loweringgoes from 22 to 20.)cargo test -p victory-shader --release: 288 passed.Exact, not approximate (second commit)
wave_localstopped at0x3ad8(_Meshlets) and0x34c4(the other): a load into the VGPR that held the wave's count, under a guard, was taken as mixed, even though it is read only under that same guard. Now a read in the same block under the same guard reads the guarded write's own value. Another guarded write over such a value keeps it that way, and every other read still sees it as mixed.local waves (idiom)form, and emit the same DXIL as the approximate form did (12e1b822fe8f9131,4f14a4f603d4fe0e). That confirms the reading from the disassembly.VICTORY_HOST_WAVE=32): every outcome and DXIL hash is identical.cargo test -p victory-shader --release: 288 passed.Not yet tested: in game (why this is a draft)
I'll mark it ready once it's been checked in a run on an RTX card.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FsQtBz4aDhUTip3jBagKEX
@Castyan on GitHub · 2026-11-27 22:20 UTC · original
i'm on it for testing
@Castyan on GitHub · 2026-11-27 22:29 UTC · original · edited 2026-11-27 23:05 UTC
#388 + #403 merged on
main(df2daaf): no conflict, no new failure. Windows, RTX 5060,cargo test --workspace --no-fail-fast: 1070 passed (main 1064, the +6 are #403's new tests), 2 failed (victory-gpuindirect::tests, the same 2 onmain). The clippy error atvictory-formats/src/texture.rs:1346is onmaintoo. Not tested in game or withtranslate --list.#388 adds no test of its own.
In game (RTX 5060 8 GB, 15 GB RAM, below the README's 32 GB):
CS_CollectTriangles_Meshletstranslates and gets its host pipeline. Series S + 2x frame gen ran 11 min, then device removed (0x887A0007). Series X runs out of memory after 2-3 min (E_OUTOFMEMORY), withmaintoo (driver access violation innvwgf2umx.dll). So the crashes look like this PC's memory, not these PRs. Not a like-for-like comparison.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.