shader: allow s_load into high SGPRs s[104:107] in gfx2hlsl (Part of #1723) #2057
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!2057
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2057/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:44 UTC · original
tedin7:x2w-r22-sload-s104→main· +261 −1 · 3 files · 8 commits · merged 2026-11-25 22:55 UTCPart of #1723
What this unblocks: 224 draw refusals (s_load into s[104:107]).
The translator refused any
s_loadwhose destination ended above s105. s106/s107 are vcc, sos_load_dwordx4 s[104:107], <table ptr>, immwas refused even though a descriptor load emits no code: it only records which table bytes the registers name. Now a descriptor load may end in s[104:107]. A root constant-buffer load (which must write the registers), a load starting above s105, and a destination past s107 are still refused.Note: later code must not read vcc before redefining it. Compilers do not do this after a descriptor load.
Verification: (run locally in the worktree on Linux; the Win2025 run is not done)
python3 -B tests/startup_gfx2hlsl_sload_s104_check.py-> ok (fails on main withs_load destination s[104:107] for 4 dwords)python3 -B tests/startup_gfx2hlsl_{smem_offset,op_refusals,readfirstlane_uniform,operand_count,capture}_check.py-> all exit 0startup_gfx2hlsl_sload_s104.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:45 UTC · original · edited 2026-11-24 23:52 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
de88ff3ℹ️ 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.
@ -3622,0 +3695,4 @@if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[1] > 105 or dst[2] > 107:raise Unsupported('s_load destination %s for %d dwords' % (ops[0], count))# s106/s107 are vcc: only a descriptor load, which emits no code, may end there (s[104:107]).into_vcc = dst[2] > 105@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:52 UTC · original
When a newly accepted high-SGPR load is followed by a VCC read before redefinition, the read still uses the old runtime mask. For example,
s_load_dwordx4 s[104:107], s[8:9], 0, followed bys_waitcnt lgkmcnt(0)andv_cndmask_b32_e32 v0, 0, 1, now translates successfully to a select against the unchangedvcc. Recording descriptor symbols insym[106]andsym[107]does not protect these reads:u('vcc_lo'), implicit cndmask operands, and VCC branches bypassS()'s numeric-descriptor refusal. Mark VCC unavailable after an overlapping symbolic load and reject reads until it is redefined, rather than silently translating an unmodelled value.Useful? React with 👍 / 👎.
@tedin7 on GitHub · 2026-11-25 01:13 UTC · original
Fixed and pushed in e0e712d5 (VCC guard added, tests pass).
@ -3622,0 +3695,4 @@if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[1] > 105 or dst[2] > 107:raise Unsupported('s_load destination %s for %d dwords' % (ops[0], count))# s106/s107 are vcc: only a descriptor load, which emits no code, may end there (s[104:107]).into_vcc = dst[2] > 105@tedin7 on GitHub · 2026-11-25 01:28 UTC · original
Fixed in e0e712d5. After a descriptor load into s106/s107, vcc is marked unavailable. Any read (vcc/vcc_lo operands, implicit cndmask mask, s_cbranch_vcc*) is refused until vcc is written again. Covered in tests/startup_gfx2hlsl_sload_s104_check.py. Verification (Linux):
python3 tests/startup_gfx2hlsl_sload_s104_check.py-> ok. Windows/WARP not run for this change.AI-assisted; commands listed were executed locally.
@R0Y00 on GitHub · 2026-11-25 06:55 UTC · original
I fast-forwarded the original branch to
0d2e34f8, preserving your commits. The added control-flow check rejects a VCC read when an incoming path skipped the redefinition, and rejects a descriptor use when the matching symbolic load did not reach it. The focused high-SGPR, SMEM-offset, refusal, readfirstlane and scalar-arity controls passed on the updated head. The PR can now run its usual checks.@tedin7 on GitHub · 2026-11-25 12:05 UTC · original
Thanks for the fast-forward to
0d2e34f8. I checked the current head76d0f6c1, which contains it plus a merge of main.The branch cases from your review are covered on this head, so I made no code change:
s_loadis refused.These are in
tests/startup_gfx2hlsl_sload_s104_check.py, and the gfx1013 fixtures, Linux Python checks and Windows build and test jobs all pass on this head.Commands run locally on
76d0f6c1:python3 tests/startup_gfx2hlsl_sload_s104_check.py→ oktests/startup_gfx2hlsl_*_check.py(52 scripts) → all passedAI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 13:50 UTC · original
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.
We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.
AI-assisted; commands listed were executed locally.
@ChazY11 on GitHub · 2026-11-25 22:56 UTC · original
Post-merge audit of
e0da6b39: five mutations of the VCC/descriptor path walk, three caught — and the biggest survivor is caused by anorin the fixture's own assertionThe change lets
s_loadwrites[104:107], which overlaps VCC, so translation now has to prove two things along every path(
check_vcc_paths,gfx2hlsl.py:1885): a descriptor load reaches its use on all paths, and VCC is numeric at a maskread. The walk is a small worklist over blocks with a
statetaken from the lastload_descriptorand cleared bywrite_vcc.read_vccwhile a descriptor is live)write_vccstops clearing the stateif state is None or any(…)→if False)Survivor 1, and why it is the fixture's fault rather than the code's
The fixture does build the "load bypassed on one path" case:
That
oris the problem. With the multi-path check disabled, a different guard (joined at a branch target) stillraises, the assertion still passes, and the case cannot tell the two apart. The regression I injected — "a descriptor read
on a path that never loaded it is accepted" — is exactly the bug this PR exists to prevent, and the assertion would stay
green.
Splitting it into two cases would close it: one whose CFG has no join (so only
check_vcc_pathscan refuse), and one thatgenuinely joins (so the join guard is the one under test). Asserting the message exactly rather than with
oris thecheap version.
Survivor 2: every branch in the fixture has both edges leading somewhere that already decides
s_cbranch_scc0produces a taken edge and a fallthrough edge. In the fixture's cases the taken edge reaches a state thatresolves the question, so removing the fallthrough edge changes no verdict. That means the
(not term or term[0] == 'branch')conjunct — the one that makes straight-line code work at all — has no case where it is the deciding edge.A load in one block with the reader reachable only by falling into the next block would pin it, and that is the most
common real shape: a straight-line prologue that loads, followed by the code that uses the word, with no branch at all.
What the three catches do cover
The VCC side is well covered: a mask read after a descriptor load is refused, a
write_vccre-enables the read, andjump edges are followed. Those three are the semantics a title would hit, and each has a case that fails when broken.
AI-assisted; pure Python, Windows 11 build 26300, no DXC or GPU for the rows above.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:52 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
de88ff3a01ℹ️ 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".
@R0Y00 on GitHub · 2026-11-25 06:13 UTC · original · reviewed
I verified the straight-line VCC guard and reproduced two branch cases that still need checks on this head.
s_load_dwordx4 s[104:107], s[4:5], 0x20; s_cbranch_scc0can skip the only VCC redefinition and reach an implicitv_cndmask_b32read. Also, a branch can skip the descriptor load itself, while a later buffer load still uses the descriptor recorded in translation order. A VCC redefinition before a high-SGPR descriptor use can likewise clobber the recorded descriptor.I prepared a local candidate against
8150d800that checks these reads along the stage’s branch edges and preserves a matching descriptor on every path. The focused check passes the branch-bypass refusals, accepts the dominated reads, and refuses reuse after a VCC write. All 46 localstartup_gfx2hlsl_*_check.pyscripts passed. A separate replay on the local diagnostic translator with Windows SDK10.0.26100.0FXC newly produced a manifest and both shader binaries for one captured request; four others advanced to a separate unsupported instruction. This verifies translation only.