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

Manually merged
github merged 2 commits from gh-pr/79/head into gh-pr/79/base 2026-11-26 03:43:24 +00:00
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 22:01 UTC · original
lcg007xd-c:fix/permlane-console-lanes → main · +69 −0 · 1 files · 2 commits · merged 2026-11-25 23:02 UTC

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

**@⁠lcg007xd-c** on GitHub · 2026-11-25 22:01 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/79) `lcg007xd-c:fix/permlane-console-lanes` → `main` · +69 −0 · 1 files · 2 commits · merged 2026-11-25 23:02 UTC ## 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)
A compute program whose code reads other lanes runs in the console's
wave size and lane order (`console_lanes`). The test for such code
looks for `permute` (ds_permute, ds_bpermute), DPP, ds_swizzle,
v_mbcnt and v_readlane/v_writelane, but not `permlane`: a program whose
only cross-lane instruction is v_permlane16_b32 or v_permlanex16_b32
got no WaveSize and no lane relabelling, so in a release build its
lanes followed the host's wave (64 wide on some GPUs) and debug builds
stopped at cross_lane's debug_assert. Both names are matched now.

Found by lowering each VALU opcode alone in a compute program.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:43:23 +00:00
github manually merged commit e400208a30 into gh-pr/79/base 2026-11-26 03:43:24 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.