startup: treat wave32 vcc_hi as an ordinary scalar register in gfx2hlsl (Part of #1723) #2695
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2703"
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-26T02:48:43Z.
Part of #1723
What this unblocks: pixel and vertex programs that use
vcc_hias a compare or carry-out destination, a lane-mask source, or a scalar register now translate (wave32) instead of being refused, while the wave64 reading stays refused.Builds on #2698, which turned the scalar
vcc_hi/exec_hidestination crashes into refusals. Those guards stay as they are; this PR adds the lowering they leave open.What changed
In wave32 only
vcc_lois the condition mask;vcc_hiis a free scalar register that compilers allocate like any other (RDNA 2 ISA, "VCC").wave32_vcc_hirenamesvcc_hito an SGPR the program never names (taken from the top of s105 downwards) when that is exact in both wave sizes:vcc, andvcc_hior an odd SGPR as its mask (a misaligned pair in wave64, so the program is wave32), or no vector instruction writesvcc_lo(in wave64 that write would also setvcc_hi), ands_movrel*that could reach the chosen register.The second commit keeps
vcc_hirefused when a possibly-wave64 program reads VCC as a mask. Applied tovsandpsstages only.What stays refused
Everything not proven wave32 (the pair
vcc, a vector write ofvcc_lowith no wave32 proof,s_movrel*),exec_hi, and scalar writes intovcc_lo/exec_hikeep the refusals of #2698 (<op> destination vcc_hi).Tests
tests/startup_gfx2hlsl_vcc_hi_check.py(registered inCMakeLists.txt, noted indocs/startup-runtime.md): translation controls, mutation controls (compare bit not read, carry lost,vcc_hiread as zero),binarymode (fixture words assemble to the recorded words), and adrawmode with a CPU reference for the pixel readback. Onorigin/mainthe controls fail (PS translates,SCALAR_ONLY translates); with the change they pass. The refusal expectations match the text #2698 produces.Verification
python3 -B tests/startup_gfx2hlsl_vcc_hi_check.py: PASS (fails onorigin/main)python3 -B tests/startup_gfx2hlsl_vcc_hi_check.py binary llvm-mc-19: PASStests/startup_gfx2hlsl_*_check.pyrun with no arguments on this branch and onorigin/main: same result per script (export_null_drawandmul24_align_drawneed a compiler and renderer and exit 1 on both); the only new script isvcc_hi_check.0caf9c9e(default 5-slot pool),python3 x2w_pipe.py win2025 2703 --regex '^startup_gfx2hlsl_vcc_hi': dev 3/3 and release 3/3 passed (startup_gfx2hlsl_vcc_hi_controls,startup_gfx2hlsl_vcc_hi_warp,startup_gfx2hlsl_vcc_hi_hardware). The draw reads back 16 x 16 pixels of avcc_hicompare, carry and scalar use against the CPU reference; the mutation controls (compare bit dropped, carry lost,vcc_hiread as zero) fail the draw, and the controls keep the wave64 readings refused (a VALUvcc_lowrite or mask read with no wave32 proof, the 64-bitvccpair,exec_hi).vcc_hi: the ballot high word stays refused withoperand 'vcc_hi'.cmake --build --preset dev --target offscreen_checkthenctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_vcc_hi' -V.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:12:00Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
0caf9c9e0cℹ️ 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 tedin7 on 2026-11-26T03:47:45Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:47:47Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:07:26Z.
Ready for review, @MasterDomino.
Win2025 on head
0caf9c9e(default slots): dev 3/3 and release 3/3 passed (startup_gfx2hlsl_vcc_hi_controls,_warp,_hardware), including the pixel readback of the wave32vcc_hipath and the wave64 refusal controls. I merged current main into the branch twice (one blank-line conflict next to thewave32_vcc_hicall; no code change). Details are in the PR body.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:07:34Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
0caf9c9ℹ️ 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 tedin7 on 2026-11-26T03:48:50Z.
Independent re-check of the fix pushed after Ready (
48f889350: vcc_hi stays refused when a wide operand covers s107, or when a scalar word is read as a lane mask), head5d283a63e.vcc_hifollowed by av_cmp_*that rewrites it and av_cndmaskread keeps the per-lane form and translates; the same with a branch between the scalar write and the compare is refused (conservative); a load intos[106:107]followed by the compare also translates, since the compare writes last.tests/startup_gfx2hlsl_vcc_hi_check.pyreports 2 mismatches on the parent of the fix and passes with it.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:12:00Z.
Code review location:
tools/startup/gfx2hlsl.py; line 995With a descriptor load into
s[104:107](already supported byop_s_load_dwordx4), this rewrite moves explicitvcc_hiaccesses to another register but leaves the load targetings107, which aliasesvcc_hi. A synthetic bytecode fixture that initializesvcc_hito0x1234, performs that load, waits, and then readsvcc_hinow generatesv0 = 0x00001234u, although the source reads the fourth loaded word. This newly accepts a previously refused shader with stale-register output. Preserve the range alias too, or refuse overlapping loads before renaming.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:12:00Z.
Code review location:
tools/startup/gfx2hlsl.py; line 978When
vcc_hiis scalar-written and then used as an explicit select mask, this establishes wave32 but does not establish that the renamed SGPR contains the current lane's bit. Fors_mov_b32 vcc_hi, 0x55555555followed byv_cndmask_b32_e64 v2, 1.0, 2.0, vcc_hi, the emitted HLSL tests(0x55555555u & 1), so every lane selects2.0, although odd lanes must select1.0. This shader was previously refused. Require a tracked per-lane mask or an all-zero/all-one constant, or implement lane-bit extraction for full-word mask sources before allowing this lowering.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:47:44Z.
Code review location:
tools/startup/gfx2hlsl.py; line 995Confirmed and fixed in
5d283a63e. A wide operand that covers SGPR 107 (such ass_load_dwordx4 s[104:107]) writes vcc_hi, so there is no free register to rename it to.wave32_vcc_hinow returns the instructions unchanged (vcc_hi stays refused by name) when any register range covers s107.Test:
startup_gfx2hlsl_vcc_hi_check.py, "a load into s[104:107] keeps vcc_hi refused" (fails on the previous head, passes now).Commands run:
python3 tests/startup_gfx2hlsl_vcc_hi_check.pyand... binary llvm-mc-19tests/startup_gfx2hlsl_*scripts (same exit codes as before)5d283a63e:ctest --preset dev|release -R startup_gfx2hlsl_vcc_hi3/3 on both presetsAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:47:47Z.
Code review location:
tools/startup/gfx2hlsl.py; line 978Confirmed and fixed in
5d283a63e.s_mov_b32 vcc_hi, 0x55555555thenv_cndmask_b32_e64 v2, 1.0, 2.0, vcc_hiproduced(0x55555555u & 1)for every lane. A VOP3 lane-mask source that reads vcc_hi after a scalar write (or in a program with branches, where the order is unknown) now keeps vcc_hi refused. A compare or carry-out that wrote vcc_hi last keeps the per-lane form, so the existing draw fixture is unchanged.Note: an ordinary SGPR used the same way (
s_mov_b32 s7, 0x55555555then the samev_cndmask_b32_e64 ... s7) lowers the same way onmain. I left that alone here since it is not part of this change; this PR now just does not extend it to vcc_hi.Test: new fixture
SCALAR_MASKinstartup_gfx2hlsl_vcc_hi_check.py(refused with "s_mov_b32 destination vcc_hi"; fails on the previous head).Commands run: same as the first thread on this PR; Windows dev+release 3/3 on
5d283a63e.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T06:29:05Z.
Review: APPROVED
Verified the narrow VCC high proof and the original refusals after preserving the existing DPP and wave64-spill registrations. The host controls and the DXC/FXC draw all passed using WARP and RTX 4060 Laptop. Each draw matched 256 pixels and caught wrong compare, carry-out and VCC high mutations.