Track divergent re-entry into shader loop exits #832

Closed
github-bot wants to merge 1 commit from gh-pr/832/head into gh-pr/832/base
Owner

@⁠Kamiloj9 on GitHub · 2026-11-25 09:47 UTC · original
Kamiloj9:codex/shader-loop-convergence → main · +22 −1 · 1 files · 1 commits · closed without merging

Change

Treat a divergent branch's own block as part of its divergent region when a loop can reach it again before lanes reconverge. This lets split-wave lowering account for the later dynamic instances of a group barrier in that block.

Verification

  • Added a CPU regression that fails when a per-lane loop branch is classified as an all-lane block. It also checks the same loop with a wave-wide decision.
  • Offline disassembly of a captured 64-lane tiling shader showed a per-lane loop exit after group barriers before this change. With the opt-in wave-wide retry and this change, the exit combines both wave halves through LDS. The resulting Wave32 DXIL passes the Windows SDK validator. The capture and emitted shader stay local.
  • Independent review and targeted CPU checks passed. The wave-wide retry remains opt-in. Runtime behavior and the cause of the earlier system restart are unverified.
**@⁠Kamiloj9** on GitHub · 2026-11-25 09:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/832) `Kamiloj9:codex/shader-loop-convergence` → `main` · +22 −1 · 1 files · 1 commits · closed without merging ## Change Treat a divergent branch's own block as part of its divergent region when a loop can reach it again before lanes reconverge. This lets split-wave lowering account for the later dynamic instances of a group barrier in that block. ## Verification - Added a CPU regression that fails when a per-lane loop branch is classified as an all-lane block. It also checks the same loop with a wave-wide decision. - Offline disassembly of a captured 64-lane tiling shader showed a per-lane loop exit after group barriers before this change. With the opt-in wave-wide retry and this change, the exit combines both wave halves through LDS. The resulting Wave32 DXIL passes the Windows SDK validator. The capture and emitted shader stay local. - Independent review and targeted CPU checks passed. The wave-wide retry remains opt-in. Runtime behavior and the cause of the earlier system restart are unverified.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:06 +00:00
github-bot closed this pull request 2026-11-26 03:52:06 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 11:15 UTC · original

I independently checked fd6ac9eceaddae60b5d26fe60c69abba0a6ea1ca against its parent 9376fd60c0ba0e76a74c39b49b1407dbac0a64c7 with four original synthetic GFX10 control-flow fixtures.

The multi-block loop used the words be880380 7d880000 bf870001 bf810000 be890381 bf82fffb. On the parent, the VCC branch at byte 4 was classified as all-lane even though its taken arm loops back through a separate block. The PR classifies the revisited branch as divergent. It also identifies that branch for wave-wide retry, and classifies it as all-lane when explicitly widened. Three controls passed on both revisions: an acyclic lane split, a lane split that reconverges before a uniform loop backedge, and a uniform split with a separate loop body.

The untouched PR head passed the Linux shader library suite (172 passed, 2 ignored) and cargo check --offline --locked -p victory-shader --tests --target x86_64-pc-windows-msvc with Rust 1.98.1. The advertised main had identical shader and Cargo build inputs to the parent for these checks. Scope was CPU classification and Windows-target compilation. I used no game files and did not run Windows, a GPU, or a DXIL validator.

AI-assisted using Codex.

**@⁠avt0m4t48** on GitHub · 2026-11-25 11:15 UTC · [original](https://github.com/fxceless/victory-fork/pull/832#issuecomment-7160813493) I independently checked `fd6ac9eceaddae60b5d26fe60c69abba0a6ea1ca` against its parent `9376fd60c0ba0e76a74c39b49b1407dbac0a64c7` with four original synthetic GFX10 control-flow fixtures. The multi-block loop used the words `be880380 7d880000 bf870001 bf810000 be890381 bf82fffb`. On the parent, the VCC branch at byte 4 was classified as all-lane even though its taken arm loops back through a separate block. The PR classifies the revisited branch as divergent. It also identifies that branch for wave-wide retry, and classifies it as all-lane when explicitly widened. Three controls passed on both revisions: an acyclic lane split, a lane split that reconverges before a uniform loop backedge, and a uniform split with a separate loop body. The untouched PR head passed the Linux shader library suite (172 passed, 2 ignored) and `cargo check --offline --locked -p victory-shader --tests --target x86_64-pc-windows-msvc` with Rust 1.98.1. The advertised main had identical shader and Cargo build inputs to the parent for these checks. Scope was CPU classification and Windows-target compilation. I used no game files and did not run Windows, a GPU, or a DXIL validator. AI-assisted using Codex.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original · edited 2026-11-25 12:51 UTC

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head fd6ac9e into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with the errors main itself has on this machine (placed_filler_twins, depth_written, a sort, and manual implementation of .is_multiple_of() at victory-gpu/src/shadow.rs:2675; PR #841 fixes the first three), also with --all-features; this PR adds none. (Correction: my first version of this report said that the is_multiple_of one was extra here. It is in main too: my first baseline run of main did not list it, and a run with --keep-going on a clean main does.) cargo test --workspace --locked: run 1: 566 passed, 0 failed, 12 ignored; run 2: stopped at indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields (the one that fails on main itself most runs here (PR #849 and #847 fix its assertion)) and the victory-gpu test binary died with an access violation (it does that on main about 2 runs in 100, issue #850) (main alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 12:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/832#issuecomment-7162313620) · edited 2026-11-25 12:51 UTC Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `fd6ac9e` into `main` `f85101b` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails with the errors `main` itself has on this machine (`placed_filler_twins`, `depth_written`, a sort, and `manual implementation of .is_multiple_of()` at `victory-gpu/src/shadow.rs:2675`; PR #841 fixes the first three), also with `--all-features`; this PR adds none. (Correction: my first version of this report said that the `is_multiple_of` one was extra here. It is in `main` too: my first baseline run of `main` did not list it, and a run with `--keep-going` on a clean `main` does.) `cargo test --workspace --locked`: run 1: 566 passed, 0 failed, 12 ignored; run 2: stopped at `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields` (the one that fails on `main` itself most runs here (PR #849 and #847 fix its assertion)) and the `victory-gpu` test binary died with an access violation (it does that on `main` about 2 runs in 100, issue #850) (`main` alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.