shader: pixel shaders start with helper lanes inside EXEC #1574

Open
opened 2026-11-26 10:00:06 +00:00 by github-bot · 3 comments
Owner

@⁠Nawid3333 on GitHub · 2026-10-16 23:24 UTC · original

TranslateProgram starts pixel shaders with EXEC = true. Compiled pixel shaders save EXEC and run s_wqm_b64 exec, exec at entry (the entry s_wqm from #801), then restore the saved mask before exports, stores and atomics. So on RDNA, EXEC at entry holds only the covered pixels.

Vulkan lets helper invocations be inactive for group operations other than derivative and quad operations (without MaximallyReconvergesKHR), so whether the entry Ballot(true) contains helpers depends on the host. On the RX 9070 XT (LLPC) it contains them once the shader needs WQM. In Kyty the only WQM trigger is an implicit-LOD sample; the test below forces WQM with an OpDPdx. The guest can then elect a helper, and a helper's atomic has no effect on memory and returns an undefined value. DeathWhispers traced an ASTRO BOT device loss to this (Death-Whispers-U/KytyPS5@646753963a). arigandores (081a6a454) and epicmario7133 (9fd507389) made the same entry-EXEC change, and the open #761 removes helpers from ballots.

Test: a 2x1 target where only pixel 1 is covered. It reads s_bcnt1 of EXEC, the v_mbcnt rank, and whether v_readfirstlane picked this lane. With an OpDPdx added to the SPIR-V:

RX 9070 XT EXEC count rank readfirstlane picked this lane
main 4 1 no
entry EXEC = !HelperInvocation 1 0 yes

On the 7600X iGPU the test passes on main too.

The forks' change has three costs:

  • VGPR writes keep an OpSelect on !HelperInvocation while EXEC is the entry mask (in the test above, every write).
  • On the RX 9070 XT (driver 26.8.1) an export inside if (!HelperInvocation) breaks GraphicsPerspectiveSample4x: the result is the pixel-centre value instead of the average of the four samples. Hand-edited SPIR-V narrows it to that guarded store, and the iGPU passes, so I'll report it to AMD.
  • ResourceTracking has shortcuts that need the entry EXEC to be the constant true (HasActiveLane for ReadFirstLane, the LoadAddressU32 enable in ScalarReadMemory).

A possible split (not implemented yet): use the exact EXEC where the guest can observe it (EXEC reads, compare masks, saveexec, the lane v_readfirstlane picks, DS_APPEND / DS_ORDERED_COUNT, the source lanes of cross-lane reads), and "EXEC or helper" for register writes, exports and memory accesses. Where main has true, that folds back to true (x | !x). The open part is ReadFirstLane: its lane choice needs the exact mask, but the passes read its mask operand.

ASTRO BOT currently crashes earlier, in SrtWalker (#1507; #1549 addresses it), so the game can't confirm this on main yet.

Which direction would you prefer (the forks' change, the split, or something else)? I'd make a PR that follows it.

Written with Claude Code (AI): it ran the tests on my PC. I read this issue before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-16 23:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1574) `TranslateProgram` starts pixel shaders with EXEC = true. Compiled pixel shaders save EXEC and run `s_wqm_b64 exec, exec` at entry (the entry s_wqm from #801), then restore the saved mask before exports, stores and atomics. So on RDNA, EXEC at entry holds only the covered pixels. Vulkan lets helper invocations be inactive for group operations other than derivative and quad operations (without MaximallyReconvergesKHR), so whether the entry `Ballot(true)` contains helpers depends on the host. On the RX 9070 XT (LLPC) it contains them once the shader needs WQM. In Kyty the only WQM trigger is an implicit-LOD sample; the test below forces WQM with an `OpDPdx`. The guest can then elect a helper, and a helper's atomic has no effect on memory and returns an undefined value. DeathWhispers traced an ASTRO BOT device loss to this (Death-Whispers-U/KytyPS5@646753963a). arigandores (081a6a454) and epicmario7133 (9fd507389) made the same entry-EXEC change, and the open #761 removes helpers from ballots. Test: a 2x1 target where only pixel 1 is covered. It reads `s_bcnt1` of EXEC, the `v_mbcnt` rank, and whether `v_readfirstlane` picked this lane. With an `OpDPdx` added to the SPIR-V: | RX 9070 XT | EXEC count | rank | readfirstlane picked this lane | |---|---|---|---| | main | 4 | 1 | no | | entry EXEC = `!HelperInvocation` | 1 | 0 | yes | On the 7600X iGPU the test passes on main too. The forks' change has three costs: - VGPR writes keep an `OpSelect` on `!HelperInvocation` while EXEC is the entry mask (in the test above, every write). - On the RX 9070 XT (driver 26.8.1) an export inside `if (!HelperInvocation)` breaks `GraphicsPerspectiveSample4x`: the result is the pixel-centre value instead of the average of the four samples. Hand-edited SPIR-V narrows it to that guarded store, and the iGPU passes, so I'll report it to AMD. - `ResourceTracking` has shortcuts that need the entry EXEC to be the constant true (`HasActiveLane` for `ReadFirstLane`, the `LoadAddressU32` enable in `ScalarReadMemory`). A possible split (not implemented yet): use the exact EXEC where the guest can observe it (EXEC reads, compare masks, saveexec, the lane `v_readfirstlane` picks, DS_APPEND / DS_ORDERED_COUNT, the source lanes of cross-lane reads), and "EXEC or helper" for register writes, exports and memory accesses. Where main has true, that folds back to true (`x | !x`). The open part is `ReadFirstLane`: its lane choice needs the exact mask, but the passes read its mask operand. ASTRO BOT currently crashes earlier, in `SrtWalker` (#1507; #1549 addresses it), so the game can't confirm this on main yet. Which direction would you prefer (the forks' change, the split, or something else)? I'd make a PR that follows it. Written with Claude Code (AI): it ran the tests on my PC. I read this issue before posting it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:00:07 +00:00
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 02:46 UTC · original

@⁠Nmzik when you have time: which direction would you prefer here (the forks' change, the split, or something else)? I'll follow it in a PR.

Written with Claude Code (AI); I read this comment before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-17 02:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1574#issuecomment-6228664724) @⁠Nmzik when you have time: which direction would you prefer here (the forks' change, the split, or something else)? I'll follow it in a PR. Written with Claude Code (AI); I read this comment before posting it.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-17 23:09 UTC · original

RADV data point: Radeon 8060S (RDNA 3.5), Mesa 26.2.4, against 763d3be3, with a test like yours (2x1 target, only pixel 1 covered, EXEC count, v_mbcnt rank, readfirstlane pick). Main gives 4 / 1 / no here without any OpDPdx: one interpolated input is enough, because ACO loads it with lds_param_load and quad DPP and starts the shader with s_wqm_b64 exec, exec, so the entry ballot includes the helpers. With OpDPdx added it's the same, and with no interpolated input at all it's 1 / 0 / yes. So on RADV with RDNA3 any pixel shader that reads an interpolant is affected, not only those with an implicit-LOD sample.

**@⁠NeySlim** on GitHub · 2026-10-17 23:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1574#issuecomment-6242862924) RADV data point: Radeon 8060S (RDNA 3.5), Mesa 26.2.4, against 763d3be3, with a test like yours (2x1 target, only pixel 1 covered, EXEC count, `v_mbcnt` rank, readfirstlane pick). Main gives 4 / 1 / no here without any `OpDPdx`: one interpolated input is enough, because ACO loads it with `lds_param_load` and quad DPP and starts the shader with `s_wqm_b64 exec, exec`, so the entry ballot includes the helpers. With `OpDPdx` added it's the same, and with no interpolated input at all it's 1 / 0 / yes. So on RADV with RDNA3 any pixel shader that reads an interpolant is affected, not only those with an implicit-LOD sample.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-18 04:15 UTC · original

Thanks, that makes the issue much wider on RADV with RDNA3: in any pixel shader that reads an interpolant, a guest v_readfirstlane, an s_ff1 of EXEC or an atomic elected from the entry mask can pick a helper lane, not only in shaders with an implicit-LOD sample. The question about which direction to take still stands.

Written with Claude Code (AI); I read this comment before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-18 04:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1574#issuecomment-6245555793) Thanks, that makes the issue much wider on RADV with RDNA3: in any pixel shader that reads an interpolant, a guest `v_readfirstlane`, an `s_ff1` of EXEC or an atomic elected from the entry mask can pick a helper lane, not only in shaders with an implicit-LOD sample. The question about which direction to take still stands. Written with Claude Code (AI); I read this comment before posting it.
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/KytyPS5--KytyPS5#1574
No description provided.