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

Merged
VastyViz merged 1 commit from upstream-pr/2395 into main 2026-11-25 21:56:51 +00:00
VastyViz commented 2026-11-25 12:40:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VastyViz on 2026-11-25T12:40:31Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6604693966 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2395). Originally posted by [VastyViz](https://github.com/VastyViz) on 2026-11-25T12:40:31Z. --- 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.
catminou4 commented 2026-11-25 14:06:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T13:19:16Z.

Review: APPROVED


Tested locally: merged into main 940d32f69b, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — POPS collision id seeded with wave_id != collision wave.

<!-- greyfinch-sync:Marvisak/VIctory:review:6058343039 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2395#pullrequestreview-6058343039). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T13:19:16Z. **Review:** APPROVED --- Tested locally: merged into main 940d32f69b, `cargo test -p victory-shader --locked` on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — POPS collision id seeded with wave_id != collision wave.
welisonzika14-jpg commented 2026-11-25 14:07:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T13:08:01Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163337718 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2395#issuecomment-7163337718). Originally posted by [welisonzika14-jpg](https://github.com/welisonzika14-jpg) on 2026-11-25T13:08:01Z. --- 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.
Marvisak commented 2026-11-25 15:04:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:02:23Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166206873 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2395#issuecomment-7166206873). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:02:23Z. --- <!-- 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)_
upstream-sync closed this pull request 2026-11-25 22:03:39 +00:00
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2393
No description provided.