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

Merged
RVZO6 merged 1 commit from upstream-pr/865 into main 2026-11-28 19:39:38 +00:00
RVZO6 commented 2026-11-28 08:06:43 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by RVZO6 on 2026-11-28T08:06:43Z.


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
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5538165537 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/865). Originally posted by [RVZO6](https://github.com/RVZO6) on 2026-11-28T08:06:43Z. --- ## 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
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
trustno1-coder/VIctory-NVIDIA!865
No description provided.