shader: allow s_load into high SGPRs s[104:107] in gfx2hlsl (Part of #1723) #2050
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2057"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:44:59Z.
Part 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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:52:12Z.
Review: COMMENTED
💡 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".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:45:11Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:52:12Z.
Code review location:
tools/startup/gfx2hlsl.py; line 974When 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 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:28:28Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:13:47Z.
Fixed and pushed in
e0e712d5(VCC guard added, tests pass).Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:28:28Z.
Code review location:
tools/startup/gfx2hlsl.py; line 974Fixed 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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:13:54Z.
Review: COMMENTED
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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:55:37Z.
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.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:05:40Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:50:51Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T22:56:24Z.
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.