Shaders: emit waveGetLaneIndex in the entry block for console_lane and thread_id #865

Manually merged
github merged 1 commit from github-bot/gh-865 into main 2026-11-28 19:43:08 +00:00 AGit
Owner

@⁠RVZO6 on GitHub · 2026-11-28 08:06 UTC · original
RVZO6:fix/console-lane-thread-id-entry-block → main · +14 −43 · 1 files · 1 commits · merged 2026-11-28 19:39 UTC

Summary

Fixes two SSA dominance / forward-reference panics (forward reference outside a phi in crates/victory-shader/src/emit/bitcode.rs) when lowering console_lanes compute shaders that have no halves or ticket counter (such as full-32 KiB LDS Wave64 compute shaders lowered to Wave32 by #822 when paired with #733 or lower_counted):

  1. Lower::console_lane(): Previously returned self.lane_index() (which emits dx.op.waveGetLaneIndex into self.cur) when halves.is_none(). Callers such as exchange_halves(at, ...) (called from ballot_at with an earlier block at) then emitted cmp(at, pred::IUGE, cl, 32) referencing cl defined in a later block self.cur, panicking in bitcode.rs. Now emits and caches waveGetLaneIndex in self.s.entry (setting flags::WAVE_OPS) so cl dominates all blocks.
  2. Lower::thread_id(): Previously duplicated console_thread() for the halves.is_none() && ticket.is_none() fallback, calling self.lane_index() (self.cur) and using it inside self.s.m.bin(e, Bin::Add, base, lane) (self.s.entry). Now delegates unconditionally to self.console_thread(), which already emits waveGetLaneIndex into self.s.entry (also removing 34 duplicate lines from lower.rs).

Verification

  • cargo test -p xtask: 6/6 passed
  • cargo test -p victory-shader --lib: 207/207 passed
  • CARGO_FEATURE_PURE=1 cargo check --target x86_64-pc-windows-msvc -p victory-shader --tests: clean, 0 errors
**@⁠RVZO6** on GitHub · 2026-11-28 08:06 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/865) `RVZO6:fix/console-lane-thread-id-entry-block` → `main` · +14 −43 · 1 files · 1 commits · merged 2026-11-28 19:39 UTC ## Summary Fixes two SSA dominance / forward-reference panics (`forward reference outside a phi` in `crates/victory-shader/src/emit/bitcode.rs`) when lowering `console_lanes` compute shaders that have no `halves` or `ticket` counter (such as full-32 KiB LDS Wave64 compute shaders lowered to Wave32 by #822 when paired with #733 or `lower_counted`): 1. **`Lower::console_lane()`**: Previously returned `self.lane_index()` (which emits `dx.op.waveGetLaneIndex` into `self.cur`) when `halves.is_none()`. Callers such as `exchange_halves(at, ...)` (called from `ballot_at` with an earlier block `at`) then emitted `cmp(at, pred::IUGE, cl, 32)` referencing `cl` defined in a later block `self.cur`, panicking in `bitcode.rs`. Now emits and caches `waveGetLaneIndex` in `self.s.entry` (setting `flags::WAVE_OPS`) so `cl` dominates all blocks. 2. **`Lower::thread_id()`**: Previously duplicated `console_thread()` for the `halves.is_none() && ticket.is_none()` fallback, calling `self.lane_index()` (`self.cur`) and using it inside `self.s.m.bin(e, Bin::Add, base, lane)` (`self.s.entry`). Now delegates unconditionally to `self.console_thread()`, which already emits `waveGetLaneIndex` into `self.s.entry` (also removing 34 duplicate lines from `lower.rs`). ## Verification - `cargo test -p xtask`: 6/6 passed - `cargo test -p victory-shader --lib`: 207/207 passed - `CARGO_FEATURE_PURE=1 cargo check --target x86_64-pc-windows-msvc -p victory-shader --tests`: clean, 0 errors
Fixes two SSA forward-reference panics ('forward reference outside a phi'
in bitcode.rs) when lowering console_lanes compute shaders without a halves
or ticket counter (e.g. full-32 KiB LDS Wave64 shaders lowered to Wave32
in #822, or counted dispatches on ticketless console_lanes shaders):
- console_lane() returned self.lane_index() (emitted into self.cur) when
  exchange/halves were none, which exchange_halves(at, ...) then referenced
  in an earlier block at; emit and cache waveGetLaneIndex in self.s.entry.
- thread_id() called self.lane_index() (into self.cur) and added it in
  self.s.entry; delegate unconditionally to console_thread(), which already
  emits waveGetLaneIndex in self.s.entry.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:29:08 +00:00
github-bot referenced this pull request from a commit 2026-11-28 19:41:56 +00:00
github manually merged commit 188c3bb302 into main 2026-11-28 19:43:08 +00:00
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/trustno1-coder--VIctory-NVIDIA!865
No description provided.