Pixel programs that copy their primitive mask through a VGPR are refused as "a hardware SGPR input" (6 shaders) #457

Closed
opened 2026-11-27 20:24:09 +00:00 by github-bot · 4 comments
Owner

@⁠lautarocherro on GitHub · 2026-11-27 20:19 UTC · original

What happens

7 pixel programs of a 21,579-shader corpus (Series X, main b998bb65) are refused as "a hardware SGPR input". It is s17, their primitive mask. The register image confirms it: USER_SGPR is 17 in their images (#436, #455). One of them, 8cb18f43378f99c9, was bound in a world run here.

The mask only reaches M0 for v_interp, but PrimMaskUses::is_prim_mask_only does not see that:

  • In 6 of them the program also copies the mask into a VGPR with v_mov_b32 and reads it back with v_readfirstlane_b32 into a loop phi of s17. The rule follows copies, v_writelane/v_readlane spills and phis, but not this round trip, so the v_mov_b32 stops it.
  • In 1 of them the loop phi's other value is an s_buffer_load_dword. I have not looked at that one yet.

Plan

Follow a VGPR copy of the mask (v_mov_b32, VGPR phis, VGPR to VGPR copies) back to SGPRs through v_readfirstlane_b32 and v_readlane_b32. Any other read of the copy still refuses, as for spills. The code invites this: "extend the recognised scalar operations if a new compiler pattern still uses the value only for M0". Test and by-output corpus sweep with the PR. Counts and ids only.

**@⁠lautarocherro** on GitHub · 2026-11-27 20:19 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/453) ## What happens 7 pixel programs of a 21,579-shader corpus (Series X, main `b998bb65`) are refused as "a hardware SGPR input". It is s17, their primitive mask. The register image confirms it: `USER_SGPR` is 17 in their images (#436, #455). One of them, `8cb18f43378f99c9`, was bound in a world run here. The mask only reaches M0 for `v_interp`, but `PrimMaskUses::is_prim_mask_only` does not see that: - In 6 of them the program also copies the mask into a VGPR with `v_mov_b32` and reads it back with `v_readfirstlane_b32` into a loop phi of s17. The rule follows copies, `v_writelane`/`v_readlane` spills and phis, but not this round trip, so the `v_mov_b32` stops it. - In 1 of them the loop phi's other value is an `s_buffer_load_dword`. I have not looked at that one yet. ## Plan Follow a VGPR copy of the mask (`v_mov_b32`, VGPR phis, VGPR to VGPR copies) back to SGPRs through `v_readfirstlane_b32` and `v_readlane_b32`. Any other read of the copy still refuses, as for spills. The code invites this: "extend the recognised scalar operations if a new compiler pattern still uses the value only for M0". Test and by-output corpus sweep with the PR. Counts and ids only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:24:09 +00:00
Author
Owner

@⁠lautarocherro on GitHub · 2026-11-27 20:19 UTC · original

/claim

**@⁠lautarocherro** on GitHub · 2026-11-27 20:19 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/453#issuecomment-7227390895) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-27 20:19 UTC · original

Claimed by @⁠lautarocherro. Open a draft pull request with Refs #453 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-27 20:19 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/453#issuecomment-7227393394) Claimed by @⁠lautarocherro. Open a draft pull request with `Refs #453` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠lautarocherro on GitHub · 2026-11-27 20:27 UTC · original

Update: the plan above doesn't work.

Following the VGPR copy (v_mov_b32, then v_readfirstlane_b32) is not enough. In all 7 programs the copy also reaches VGPR phis that join it with other data, because the register is reused on another path, and arithmetic reads those phis (v_add_f32, v_cndmask_b32...). So "the mask only reaches M0" can't be proven from the code. A local change that follows the copy gains none of the 7 on the corpus.

A sounder route: described programs already take the SGPR after the user SGPRs as the primitive mask without that proof. With #455, the register image gives a guessed pixel program's user SGPR count (17 for all 7), so the mask's place is known, not guessed. Lowering could then treat these programs like described ones. That needs the count to reach lowering, so it builds on #455. I'll wait for #455's review before doing it.

**@⁠lautarocherro** on GitHub · 2026-11-27 20:27 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/453#issuecomment-7227528729) Update: the plan above doesn't work. Following the VGPR copy (`v_mov_b32`, then `v_readfirstlane_b32`) is not enough. In all 7 programs the copy also reaches VGPR phis that join it with other data, because the register is reused on another path, and arithmetic reads those phis (`v_add_f32`, `v_cndmask_b32`...). So "the mask only reaches M0" can't be proven from the code. A local change that follows the copy gains none of the 7 on the corpus. A sounder route: described programs already take the SGPR after the user SGPRs as the primitive mask without that proof. With #455, the register image gives a guessed pixel program's user SGPR count (17 for all 7), so the mask's place is known, not guessed. Lowering could then treat these programs like described ones. That needs the count to reach lowering, so it builds on #455. I'll wait for #455's review before doing it.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 00:42 UTC · original

The claim by @⁠lautarocherro has expired: no pull request referenced it within 24 hours. This issue is free to claim.

**@⁠github-actions[bot]** on GitHub · 2026-11-29 00:42 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/453#issuecomment-7248294724) The claim by @⁠lautarocherro has expired: no pull request referenced it within 24 hours. This issue is free to claim.
This discussion has been locked. Commenting is limited to contributors.
No description provided.