Shaders: seed POPS collision id with wave_id != collision_id #2395
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2395
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2395/head"
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?
@VastyViz on GitHub · 2026-11-25 12:40 UTC · original
VastyViz:shaders/pops-collision-id-wait-exit→main· +181 −4 · 2 files · 1 commits · merged 2026-11-25 21:56 UTCThe title's pixel ordered-section (POPS) wait loop computes:
label_wait:
s0 = src_pops_exiting_wave_id + s4
s_cmp_lt_u32 s5, s0
s_cbranch_scc0 label_wait
Seeding the POPS hardware SGPR with 0 gives wave_id == collision_id == 0, making s5 = 0 + ~0 = 0xffff_ffff so s5 <u s0 can never hold for any u32 exiting wave id. While active lanes skip the loop on overlap == 0, any inactive lane (where EXEC is clear at s_cbranch_vccnz) falls through and spins to LOOP_LIMIT (1 << 20 iterations).
Seeding 1 << 16 (overlap = 0, wave_id = 1, collision_id = 0) satisfies the hardware invariant wave_id != collision_id so s5 = 0 and s0 = 0xffff_ffff with src_pops_exiting_wave_id = 0, exiting immediately on the first check.
Add a WARP draw test reproducing the 1 << 20 spin and verifying it drops to a single pass.
The title's pixel ordered-section (POPS) wait loop computes: s2 = bfe(s_pops, 0, 10) ; collision wave id s5 = bfe(s_pops, 16, 10) ; this wave id s4 = ~s2 s5 = s5 + s4 ... s_cbranch_vccnz label_body label_wait: s0 = src_pops_exiting_wave_id + s4 s_cmp_lt_u32 s5, s0 s_cbranch_scc0 label_wait Seeding the POPS hardware SGPR with 0 gives wave_id == collision_id == 0, making s5 = 0 + ~0 = 0xffff_ffff so s5 <u s0 can never hold for any u32 exiting wave id. While active lanes skip the loop on overlap == 0, any inactive lane (where EXEC is clear at s_cbranch_vccnz) falls through and spins to LOOP_LIMIT (1 << 20 iterations). Seeding 1 << 16 (overlap = 0, wave_id = 1, collision_id = 0) satisfies the hardware invariant wave_id != collision_id so s5 = 0 and s0 = 0xffff_ffff with src_pops_exiting_wave_id = 0, exiting immediately on the first check. Add a WARP draw test reproducing the 1 << 20 spin and verifying it drops to a single pass.@welisonzika14-jpg on GitHub · 2026-11-25 13:08 UTC · original
First run on NVIDIA hardware here, as far as I can see. RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head
0b239a7merged ontomain940d32f,cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.The PR's new test(s) pass on this card:
emit::synthetic_tests::pops_wait_loop_exits_immediately_for_inactive_lanes. The rest is the same asmainon this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests invictory-gpu, 3 invictory-shader), nothing new.One run, unit tests only, title not run.
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
@Marvisak on GitHub · 2026-11-25 15:02 UTC · original
Automated triage for the maintainers.
Merge candidate. In
Lower(crates/victory-shader/src/emit/lower.rs, hardware SGPR inputs), the POPS collision-id SGPR is now seeded as1 << 16(no overlap, wave id 1, collision id 0) instead of 0, while the exiting wave id stays 0. The evidence is the title's own wait loop quoted in the description. I worked it through: with 0,s5 = 0 + ~0 = 0xFFFF_FFFFands_cmp_lt_u32 s5, s0can never hold, so a wave reaching the wait spins to the loop limit. With1 << 16,s5 = 0ands0 = 0 + ~0, so it exits on the first test. Ordering still comes from the host's rasterizer-ordered views, as before. The draw test reproduces the spin onmainand passes here.CI:
checkpassing. A contributor reports the new test passing on an RTX 5070.Generated by Claude Code