Shaders: lane-indexed reads/writes on a 64-lane host wave use the wrong console wave or are refused #593

Open
opened 2026-11-26 04:09:30 +00:00 by github-bot · 3 comments
Owner

@⁠NolanCotter on GitHub · 2026-11-24 05:17 UTC · original

Same family as #131/#125, one level up: for MaskData::Host (pixel/vertex programs, no WaveSize, so the host wave can be 64 lanes = two console waves), the lane-indexed ops either refuse or read the wrong wave.

crates/victory-shader/src/emit/lower.rs, valu_op:

  • v_readlane_b32 with a constant lane takes cross_lane(false) → a cross-lane operation outside compute → the whole program is refused. On a wave32 program under a 64-lane host wave, console lane k of the lane's own wave is host lane k | (lane & 32) — expressible, no refusal needed. The same refusal hits wave64 programs, where a constant lane is already a valid host lane and should just work.
  • v_writelane_b32 calls cross_lane(false) unconditionally → refused on every pixel/vertex program, computed lane or not. On host lanes, me == lane is already the correct host-space test for a computed lane; a constant lane needs the same | (lane & 32) base.
  • v_readfirstlane_b32 emits waveReadLaneFirst → the host wave's first active lane — wave A's lane 0 — for lanes 32-63, whose console wave's first lane is a lane of the ballot's high half + 32.

Repro (synthetic wave32 pixel program, v_readlane v4, v2, 5): the write is dropped (a cross-lane operation outside compute), the register reads back its input 0, and the op list shows no waveReadLaneAt.

Found while continuing #131: mask-as-number reads were fixed there; these are the lane-index uses the same host-wave model needs.

**@⁠NolanCotter** on GitHub · 2026-11-24 05:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/593) Same family as #131/#125, one level up: for `MaskData::Host` (pixel/vertex programs, no `WaveSize`, so the host wave can be 64 lanes = two console waves), the lane-indexed ops either refuse or read the wrong wave. `crates/victory-shader/src/emit/lower.rs`, `valu_op`: - `v_readlane_b32` with a **constant** lane takes `cross_lane(false)` → `a cross-lane operation outside compute` → the whole program is refused. On a wave32 program under a 64-lane host wave, console lane `k` of the lane's own wave is host lane `k | (lane & 32)` — expressible, no refusal needed. The same refusal hits **wave64** programs, where a constant lane is already a valid host lane and should just work. - `v_writelane_b32` calls `cross_lane(false)` unconditionally → refused on every pixel/vertex program, computed lane or not. On host lanes, `me == lane` is already the correct host-space test for a computed lane; a constant lane needs the same `| (lane & 32)` base. - `v_readfirstlane_b32` emits `waveReadLaneFirst` → the host wave's first active lane — wave A's lane 0 — for lanes 32-63, whose console wave's first lane is a lane of the ballot's high half + 32. Repro (synthetic wave32 pixel program, `v_readlane v4, v2, 5`): the write is dropped (`a cross-lane operation outside compute`), the register reads back its input `0`, and the op list shows no `waveReadLaneAt`. Found while continuing #131: mask-as-number reads were fixed there; these are the lane-index uses the same host-wave model needs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:09:30 +00:00
Author
Owner

@⁠NolanCotter on GitHub · 2026-11-24 05:17 UTC · original

Claiming this (same author as #434). Will implement the host-wave fix in v_readlane/v_writelane/v_readfirstlane lowering with synthetic GFX10 tests, no game files.

**@⁠NolanCotter** on GitHub · 2026-11-24 05:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/593#issuecomment-7122810466) Claiming this (same author as #434). Will implement the host-wave fix in `v_readlane`/`v_writelane`/`v_readfirstlane` lowering with synthetic GFX10 tests, no game files.
Author
Owner

@⁠NolanCotter on GitHub · 2026-11-24 05:20 UTC · original

Fixed in #599 (head 3823462): constant console lanes take the lane's own wave's 32-lane base on wide host waves, wave64 const lanes read directly, and v_readfirstlane picks the low bit of its own ballot half. Synthetic wave32 test asserts the emitted ops; 59/59 victory-shader tests pass. No game files.

**@⁠NolanCotter** on GitHub · 2026-11-24 05:20 UTC · [original](https://github.com/Marvisak/VIctory/issues/593#issuecomment-7122859805) Fixed in #599 (head 3823462): constant console lanes take the lane's own wave's 32-lane base on wide host waves, wave64 const lanes read directly, and v_readfirstlane picks the low bit of its own ballot half. Synthetic wave32 test asserts the emitted ops; 59/59 victory-shader tests pass. No game files.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:49 UTC · original

Automated triage for the maintainers.

Confirmed on current main (940d32f), in crates/victory-shader/src/emit/lower.rs, in the VALU lowering:

  • v_readlane_b32 with a constant lane calls cross_lane(false) when mask_data is MaskData::Host, and outside compute that refuses the program ("a cross-lane operation outside compute"). Only a computed lane is read as a host lane.
  • v_writelane_b32 calls cross_lane(false) unconditionally, so every pixel/vertex program using it is refused.
  • v_readfirstlane_b32 (apart from the waterfall-read case) emits waveReadLaneFirst, which returns the host wave's first active lane, not the first lane of the lane's own console wave.

Open PR #599 addresses this. It depends on #434 and needs a rebase.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/593#issuecomment-7149990736) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T05:20:44Z at=2026-11-25T01:50:30Z --> Automated triage for the maintainers. Confirmed on current `main` (`940d32f`), in `crates/victory-shader/src/emit/lower.rs`, in the VALU lowering: - `v_readlane_b32` with a constant lane calls `cross_lane(false)` when `mask_data` is `MaskData::Host`, and outside compute that refuses the program ("a cross-lane operation outside compute"). Only a computed lane is read as a host lane. - `v_writelane_b32` calls `cross_lane(false)` unconditionally, so every pixel/vertex program using it is refused. - `v_readfirstlane_b32` (apart from the waterfall-read case) emits `waveReadLaneFirst`, which returns the host wave's first active lane, not the first lane of the lane's own console wave. Open PR #599 addresses this. It depends on #434 and needs a rebase. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#593
No description provided.