Shaders: a lane-branch region that only raises an LDS flag runs as two host waves (one more wave64 compute on NVIDIA) #592
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/fxceless--victory-fork!592
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-592"
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?
@FrancescoGelosoEterea on GitHub · 2026-11-25 02:45 UTC · original
FrancescoGelosoEterea:lds-flags→main· +339 −2 · 2 files · 1 commits · openWhy
On a 32-lane host (NVIDIA), a console wave64 compute program with LDS in a group over 32 threads runs as two host waves.
lds_meetingsmakes them meet at group barriers on the edges of every lane-branch region that touches LDS. It refuses a region that both reads and writes LDS, because a read inside it may miss the other host wave's write. Such a program stays atWaveSize(64), which the driver refuses:This is
sr_tracing:CS_Tiling_Generate_Opaque, one of the wave64 computes still refused on NVIDIA (#7, #11). It uses LDS only as two group-wide flags. One lane zeroes them. Inside per-lane branches and a loop, lanes write1to one flag and read it back to leave the loop early. After the region, every lane reads both flags.What
The new
lds_flag_regioninemit/lower.rschecks a region that reads and writes LDS. If the check passes,lds_meetingskeeps the region instead of refusing it. The barriers on its edges stay the same as for any other region. The check requires all of the following:ds_read_b32ords_write_b32at a constant address, and every write stores the same constant;Under these conditions a read that misses the other half's write changes nothing the region leaves behind:
So the flag ends up raised exactly when some lane raises it, as on the console, and nothing else depends on when the lane saw it.
VICTORY_LDS_FLAGS=0turns the check off.For this program the lowering then takes the exact "local waves (idiom)" form, not an approximate one, with
WaveSize(32). In the emitted DXIL all 8 group barriers sit in blocks every thread reaches (the entry and the joins after the branches), never inside a branch.Tested
RTX 5070 Ti, driver 621.24, Windows 11. Own 1.0.2.1 copy.
translate --validate --pipelines --listonshaders.rpfwithVICTORY_HOST_MAX_WAVE=32, basec96b4f2against this branch): of 25,889 programs, exactly one changes:2cc4c197…goes from refused (E_INVALIDARG) to created. Nothing is lost. Compute pipelines created go from 2,645 to 2,646; every other count (emitted, validated, graphics and mesh pipelines) is the same.wave64_tests.rs, on a hand-assembled 64-thread program.WaveSize(32). This test fails withVICTORY_LDS_FLAGS=0.cargo test -p victory-shader --lib: 216 passed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.VICTORY_SPLIT_LDS=1):host pipeline shaders=[compute 2cc4c197ee29e291]is created and bound;02384a60…and6b82bc7d….The two that are left (
CS_DefragHeap_ComputeRelocations,CS_CollectTriangles_Meshlets) use LDS atomics and lane reads across halves, which this check does not cover.🤖 Generated with Claude Code
bare_command_costsays about the indirect clamp #696@Dathinel on GitHub · 2026-11-25 19:25 UTC · original
Tested the lowerer from
8bc48bfond510ee4with an RTX 3050 Laptop (4 GB, driver 32.0.16.1062). The PR's two wave-size tests passed. I also dispatched its synthetic LDS flag program with one UAV output per thread, so a missing write could not pass as a cleared flag.VICTORY_LDS_FLAGS=0, the same test binary stopped at host compute pipeline creation with an invalid-parameter error.The inputs exercise both sides of the 32-thread boundary, each scalar branch outcome, and both same-value flag variants. This measures the synthetic program only. AI-assisted test and review.
Reproduce the hardware check
Append the following test to
crates/victory-shader/src/emit/wave64_tests.rswith the PR applied. Runcargo test --locked -p victory-shader --lib -- lds_flag_rtx_readback --nocaptureon the hardware adapter. Repeat with the environment variable above for the control.@HAL9000RELOADED on GitHub · 2026-11-25 19:29 UTC · original
RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main
d510ee4: both new tests pass on the card with this PR. With the tests alone on the base,a_branch_that_only_raises_an_lds_flag_runs_in_waves_of_32fails. No other test changed. Run table: #129 (#129).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.