Shaders: seed POPS collision id with wave_id != collision_id #2395

Manually merged
github merged 1 commit from gh-pr/2395/head into gh-pr/2395/base 2026-11-26 05:04:34 +00:00
Owner

@⁠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 UTC

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.

**@⁠VastyViz** on GitHub · 2026-11-25 12:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2395) `VastyViz:shaders/pops-collision-id-wait-exit` → `main` · +181 −4 · 2 files · 1 commits · merged 2026-11-25 21:56 UTC 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.
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:33 +00:00
github manually merged commit 0b239a745d into gh-pr/2395/base 2026-11-26 05:04:34 +00:00
Author
Owner

@⁠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 0b239a7 merged onto main 940d32f, 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 as main on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in victory-gpu, 3 in victory-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.

**@⁠welisonzika14-jpg** on GitHub · 2026-11-25 13:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2395#issuecomment-7163337718) 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 `0b239a7` merged onto `main` `940d32f`, `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 as `main` on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in `victory-gpu`, 3 in `victory-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.
Author
Owner

@⁠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 as 1 << 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_FFFF and s_cmp_lt_u32 s5, s0 can never hold, so a wave reaching the wait spins to the loop limit. With 1 << 16, s5 = 0 and s0 = 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 on main and passes here.

CI: check passing. A contributor reports the new test passing on an RTX 5070.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2395#issuecomment-7166206873) <!-- victory-triage v1 head=0b239a745dc385f99bfac686c75cb9d8b68bcd51 verdict=merge-candidate at=2026-11-25T15:02:11Z --> 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 as `1 << 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_FFFF` and `s_cmp_lt_u32 s5, s0` can never hold, so a wave reaching the wait spins to the loop limit. With `1 << 16`, `s5 = 0` and `s0 = 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 on `main` and passes here. CI: `check` passing. A contributor reports the new test passing on an RTX 5070. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2395
No description provided.