shader: a spilled SGPR reloaded inside a whole-wave section is the SGPR (#417) #423

Manually merged
github merged 1 commit from github-bot/gh-419 into main 2026-11-28 00:29:53 +00:00 AGit
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-27 17:31 UTC · original
tiagonogueiraa-bit:shader-section-spill-readlane → main · +32 −0 · 3 files · 1 commits · merged 2026-11-28 00:28 UTC

Refs #421

Shape. 8 pixel shaders were refused as "a cross-lane operation outside compute: v_readlane_b32 of a constant lane in a pixel program". In each, the v_readlane_b32 reloads an SGPR the program spilled (v_writelane_b32 v127, s15, 1 … v_readlane_b32 s54, v127, 1), inside a whole-wave section just before a reduction. Outside a section, Lower::spill_slot turns such a reload into the spilled SGPR. Inside, the section simulation gives Shape::ReadLane, a real lane read, which a pixel program cannot make.

Change. When every path fills that lane with v_writelane_b32 (spill_slot(.., make = false) succeeds), Shape::ReadLane returns the spill slot instead of a lane read. Any other ReadLane is unchanged. In compute this case would also have read the lane, which holds the same SGPR, but no compute output changed in the sweep.

By-output corpus sweep. 26,849 containers from my own runs (Series S, boot to the story load), native host options, main b998bb6 against this head:

Stage Gained Lost Changed Other reason now
pixel 8 0 0 0
vertex 0 0 0 0
compute 0 0 0 0

Gained: 1a3e1defd07a2f26, 32d13d5707f5750d, 62f33c0ea0b0698a, 8d9a7c1b0dc8de53, c9489a35f1a79d0d, ee454af0cba74869, f1958b1a9d66126f, ff06abebd5ca9be3. All 8 convert with Apple's Metal Shader Converter 4.0 beta 3.

Test. emit::gfx_refusal_tests::a_pixel_program_reads_back_a_spilled_sgpr_inside_a_whole_wave_section is the existing two-path spill test's shape inside a section. It lowers with no WaveReadLaneAt. On main it is refused with the message above.

Checks.

  • cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 1054 passed, 0 failed, 11 ignored.
  • Windows clippy -D warnings: clean.
  • cargo xtask policy: ok.

docs/native-host.md (whole-wave sections) has a short note. @⁠Olima34, for the board.

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-27 17:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/419) `tiagonogueiraa-bit:shader-section-spill-readlane` → `main` · +32 −0 · 3 files · 1 commits · merged 2026-11-28 00:28 UTC Refs #421 **Shape.** 8 pixel shaders were refused as "a cross-lane operation outside compute: v_readlane_b32 of a constant lane in a pixel program". In each, the `v_readlane_b32` reloads an SGPR the program spilled (`v_writelane_b32 v127, s15, 1` … `v_readlane_b32 s54, v127, 1`), inside a whole-wave section just before a reduction. Outside a section, `Lower::spill_slot` turns such a reload into the spilled SGPR. Inside, the section simulation gives `Shape::ReadLane`, a real lane read, which a pixel program cannot make. **Change.** When every path fills that lane with `v_writelane_b32` (`spill_slot(.., make = false)` succeeds), `Shape::ReadLane` returns the spill slot instead of a lane read. Any other `ReadLane` is unchanged. In compute this case would also have read the lane, which holds the same SGPR, but no compute output changed in the sweep. **By-output corpus sweep.** 26,849 containers from my own runs (Series S, boot to the story load), native host options, main `b998bb6` against this head: | Stage | Gained | Lost | Changed | Other reason now | |---|---|---|---|---| | pixel | 8 | 0 | 0 | 0 | | vertex | 0 | 0 | 0 | 0 | | compute | 0 | 0 | 0 | 0 | Gained: `1a3e1defd07a2f26`, `32d13d5707f5750d`, `62f33c0ea0b0698a`, `8d9a7c1b0dc8de53`, `c9489a35f1a79d0d`, `ee454af0cba74869`, `f1958b1a9d66126f`, `ff06abebd5ca9be3`. All 8 convert with Apple's Metal Shader Converter 4.0 beta 3. **Test.** `emit::gfx_refusal_tests::a_pixel_program_reads_back_a_spilled_sgpr_inside_a_whole_wave_section` is the existing two-path spill test's shape inside a section. It lowers with no `WaveReadLaneAt`. On main it is refused with the message above. **Checks.** - `cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask`: 1054 passed, 0 failed, 11 ignored. - Windows clippy `-D warnings`: clean. - `cargo xtask policy`: ok. `docs/native-host.md` (whole-wave sections) has a short note. @⁠Olima34, for the board.
The title's pixel programs reload an SGPR they spilled to a VGPR lane
(v_writelane_b32, then v_readlane_b32 of that lane) inside a whole-wave
section, just before a reduction. The section's shape for the reload is
a constant-lane read, which a pixel program cannot make, so it was
refused. When every path fills that lane with v_writelane_b32,
Shape::ReadLane now takes Lower::spill_slot, as the reload already does
outside a section.

Corpus sweep (26,849 shaders, main b998bb6): 8 pixel shaders gained,
all of which convert with Apple's converter. No regressions, no changed
outputs.

Refs #417
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 17:39:08 +00:00
github manually merged commit f9f7ae8274 into main 2026-11-28 00:29:53 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.