shader: lower v_readlane_b32 and v_permlanex16_b32 in gfx2hlsl (Part of #1723) #2032
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2032
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2032/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tedin7 on GitHub · 2026-11-24 23:30 UTC · original
tedin7:x2w-r20-readlane-perm→main· +67 −0 · 3 files · 2 commits · closed without mergingPart of #1723
What this unblocks: Run 20 census #17 (40/39 pairs),
v_readlane_b32andv_permlanex16_b32.Branch:
x2w-r20-readlane-perm(local, not pushed).Changes in
tools/startup/gfx2hlsl.py:v_readlane_b32 sD, vS, sel:sD = vS, only whenvSis a proven uniform VGPR (same rule asv_readfirstlane_b32). The model runs one lane, so any lane gives the same word. The lane select may be an SGPR or inline constant.v_permlanex16_b32 vD, vS, s0, s1:vD = vSfor a proven uniformvS;vDstays uniform.Verification:
python3 -I tests/startup_gfx2hlsl_readlane_perm_check.py-> PASS (new test, registered in CMakeLists.txt asstartup_gfx2hlsl_readlane_perm).origin/maintools -> fails withUnsupported: v_readlane_b32.python3 -I tests/startup_uniform_lane_check.py-> PASSpython3 -I tests/startup_gfx2hlsl_op_refusals_check.py-> PASSAI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:31 UTC · original · edited 2026-11-24 23:37 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
5d64e8bℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:37 UTC · original
On a pixel wave with a sparse entry EXEC mask,
exec_knownonly means EXEC still equals its entry value, anduniform_vis populated by a conversion that writes active lanes only. Consequently, an acceptedv_permlanex16_b32 v5, v4, 0, 0in lane 0 can select inactive lane 16: with default FI=0/BOUND_CTRL=0, it retains the oldv5, whereas this path emitsv5 = v4and marks the result uniform. For example, initializingv5to 9 and converting a scalar-buffer value of 1.0 intov4produces 9 on the guest but 1 in the translation. Require proof that selected source lanes are active, or model/refuse the inactive-source case before applying this identity.Useful? React with 👍 / 👎.
@denn0x on GitHub · 2026-11-25 00:55 UTC · original
Thanks. One question on the uniform rule, and some numbers.
Inactive lanes.
uniform_vis set when a VGPR is written from a uniform SGPR while exec still equals the entry mask. Lanes outside that mask never receive the word.v_readlane_b32reads the named lane whatever EXEC says, so take a partly filled wave and a lane select that names a lane outside the entry mask. As I read the ISA, the hardware returns whatever that lane's VGPR still holds, but the translation returns the uniform word.v_permlanex16_b32without FI likewise depends on whether the source lane is active. I have not built a hardware case for either. Is the uniform proof meant to cover lanes that are not in the entry mask? If not, the restriction would need either a source written for every lane (whole-wave orv_writelane), or a note that the result is only proven for active lane selects.Coverage on real programs (a private executable's ordinary pixel/vertex requests, decode and translate only, aggregate counts):
v_readlane_b32in the pixel stage.v_readfirstlane_b32 requires a proven uniform source.v_readlane_b32 sN, vM, 31(852) andv_permlanex16_b32 ..., 0, 0(1,085) appear together withrow_mirror/row_half_mirrorDPP. That looks like a wave reduction.v_writelane_b32/v_readlane_b32pairs with lane constants 0, 1, 2, ... (hundreds per lane index) look like SGPR values spilled into the lanes of one VGPR.The spill shape can be lowered exactly without a cross-lane model: each lane index of that VGPR becomes a separate scalar slot, written by
v_writelaneand read byv_readlanewith the same constant. That could be a separate item if someone wants it.@tedin7 on GitHub · 2026-11-25 00:56 UTC · original
Fixed in
f2a28b42(rebased on main, push pending). Agreed: uniformity is only proven over active lanes, so the selected source lane can be inactive. The same hole exists in v_readlane_b32. Both ops now refuse with "requires every selected source lane to be proven active", and the test asserts the refusals. Ran locally: python3 -B tests/startup_gfx2hlsl_readlane_perm_check.py and every tests/startup_gfx2hlsl_*check.py (all pass).AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 10:46 UTC · original
@denn0x thanks, you are right: the uniform proof only covers lanes in the entry mask, so it cannot vouch for a lane select outside it.
Fixed in
f2a28b42:v_readlane_b32andv_permlanex16_b32are now refused, because the selected source lane may be inactive and its VGPR content is not provable. The check istests/startup_gfx2hlsl_readlane_perm_check.py(see the comment near line 36, which covers the sparse-EXEC permlanex16 case).Thank you for the coverage numbers. The lane-spill shape (
v_writelane_b32/v_readlane_b32with matching constants) can be lowered exactly as separate scalar slots, so it can be a separate item.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 10:59 UTC · original
Closing:
mainalready lowersv_readlane_b32for SGPR spill slots (so this PR's refusal definition shadows it and would breakstartup_gfx2hlsl_sgpr_spill_check.py), andv_permlanex16_b32is already refused by default.@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:37 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
5d64e8bcc5ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pull request closed