Shaders: v_permlane16/v_permlanex16 run in the console's lanes (were missed by the cross-lane check) #79

Merged
lcg007xd-c merged 2 commits from upstream-pr/79 into main 2026-11-25 23:02:08 +00:00
lcg007xd-c commented 2026-11-25 22:01:42 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by lcg007xd-c on 2026-11-25T22:01:42Z.


What

A compute program whose code reads other lanes has to run in the console's wave size and lane order (console_lanes: a WaveSize, and threads relabelled so host lane = console lane). The check for such code matches ds_swizzle, permute (ds_permute/ds_bpermute), DPP, v_mbcnt and v_readlane/v_writelane. It misses v_permlane16_b32 / v_permlanex16_b32: their names say permlane, not permute. The comment just below already counts them as cross-lane code.

So take a program whose only cross-lane instruction is a permlane, with a group larger than one wave and no LDS:

  • Release builds: the program got no WaveSize and no relabelling, so its permlanes read whichever lanes the host's wave put there (64 wide on some GPUs).
  • Debug builds: it stopped at cross_lane's debug_assert!(threads.is_none() || console_lanes).

Both names now count as cross-lane code.

How it was found

I lowered every VALU opcode on its own in a small compute program. v_permlane16_b32 and v_permlanex16_b32 were the only ones that panicked instead of lowering or returning Unsupported.

Test

permlanes_ask_for_console_lanes lowers each of the two in a 64-thread group, with LLVM's encoding of v_permlane16_b32 v0, v1, s1, s2 and the 0x378 equivalent. It checks that the result declares wave operations and runs in waves of 32. Without the fix, it fails in a debug build at the debug_assert, and in --release with wave_size None instead of Some(32).

The portable CI commands and Windows-target clippy (--target x86_64-pc-windows-msvc) pass locally.

Not tested: running a permlane shader on a GPU, so the lane results themselves are unchecked.

🤖 Generated with Claude Code

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:6614642371 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/79). Originally posted by [lcg007xd-c](https://github.com/lcg007xd-c) on 2026-11-25T22:01:42Z. --- ## What A compute program whose code reads other lanes has to run in the console's wave size and lane order (`console_lanes`: a `WaveSize`, and threads relabelled so host lane = console lane). The check for such code matches `ds_swizzle`, `permute` (`ds_permute`/`ds_bpermute`), DPP, `v_mbcnt` and `v_readlane`/`v_writelane`. It misses `v_permlane16_b32` / `v_permlanex16_b32`: their names say `permlane`, not `permute`. The comment just below already counts them as cross-lane code. So take a program whose only cross-lane instruction is a permlane, with a group larger than one wave and no LDS: - **Release builds:** the program got no `WaveSize` and no relabelling, so its permlanes read whichever lanes the host's wave put there (64 wide on some GPUs). - **Debug builds:** it stopped at `cross_lane`'s `debug_assert!(threads.is_none() || console_lanes)`. Both names now count as cross-lane code. ## How it was found I lowered every VALU opcode on its own in a small compute program. `v_permlane16_b32` and `v_permlanex16_b32` were the only ones that panicked instead of lowering or returning `Unsupported`. ## Test `permlanes_ask_for_console_lanes` lowers each of the two in a 64-thread group, with LLVM's encoding of `v_permlane16_b32 v0, v1, s1, s2` and the 0x378 equivalent. It checks that the result declares wave operations and runs in waves of 32. Without the fix, it fails in a debug build at the `debug_assert`, and in `--release` with `wave_size` `None` instead of `Some(32)`. The portable CI commands and Windows-target clippy (`--target x86_64-pc-windows-msvc`) pass locally. Not tested: running a permlane shader on a GPU, so the lane results themselves are unchecked. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
uiliannn/VItoriaBr!79
No description provided.