startup: lower DPP quad reads in pixel programs with uniform branches and loops (Part of #1723) #2697
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2705"
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:54:55Z.
Part of #1723
What this unblocks: pixel programs that read a DPP quad neighbour (quad swap, quad broadcast, pair broadcast) and also have a uniform branch or loop now translate; today any branch or loop after the first read, or around it, is refused.
Extends #2657 and #2483: #2657 accepts a broadcast in the entry prefix when a loop follows; this PR proves the same property for reads inside branches and loops.
What changed
The one-lane model runs each guest lane as its own HLSL thread through the pc dispatch, and
QuadReadLaneAtonly sees a neighbour when the four threads of a quad reach the statement together. The old check required straight-line code (or, since #2657, the entry prefix) instead of proving that.Stage.quad_flow_refusalsproves it over the whole program after translation:s_wqm_b64 exec, execruns before every branch and branch target;execz/execnzunder the whole-quad mask).No wave size is assumed (SM 6.0 quad operations need only the 2x2 quad). The second commit keeps the entry-prefix test for stage objects that never run
translate()(unit probes), so #2657's fixtures behave as before.What stays refused
vccz/vccnzloops, SCC derived from a lane mask, an EXEC write inside the loop, and a lates_wqm, each with the offset that breaks the proof. The vertex stage and any DPP form other than the lowered quad reads.Tests
New
tests/startup_gfx2hlsl_dpp_quad_flow_check.py(registered inCMakeLists.txt, noted indocs/startup-runtime.md): controls for the accepted loop and the four refusal reasons, mutation controls for wrong-lane reads, and adrawmode with a CPU reference for a 16 x 16 readback. Onorigin/mainthe controls fail (LOOP translates, and the four refusal reasons are absent); with the change they pass.Verification
python3 -B tests/startup_gfx2hlsl_dpp_quad_flow_check.py: PASS (fails onorigin/main)python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py,..._dpp_quad_swap_check.py,..._dpp_pair_check.py: 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 isdpp_quad_flow_check.fc3afb5c0, dev and release: 12/12 passed in each, includingstartup_gfx2hlsl_dpp_quad_flow,_warpand_hardware(the 16 x 16 draw against the CPU reference, with the wrong-lane control failing as required).Commands (run per preset
devandrelease):AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:04:29Z.
@MasterDomino Independent Stage-2 gate review of head
e9283e3e9: PASS, marked Ready.tests/startup_gfx2hlsl_dpp_quad_flow_check.pyexits 1 onorigin/mainand passes on this head.s_andn2 exec) is refused with the EXEC-write reason; a lates_wqm, avcczloop and SCC from a lane mask are refused; the uniform loop translates.startup_gfx2hlsl_dpp_quad_flow,_warp,_hardwareincluded).Commands executed:
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:04:36Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
e9283e3ℹ️ 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-26T04:16:48Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
e9283e3e93ℹ️ 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-26T04:19:39Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:24:47Z.
Re-checked the fix for the empty branch set on head
fc3afb5c0(resolving the thread).min(..., default=inf)leaves a branch-free program with nothing for thes_wqmto precede, and the rest of the proof still runs (a missings_wqmand any EXEC write that reaches the read are still refused).tests/startup_gfx2hlsl_dpp_quad_flow_check.pyfails when the fix is removed (exception) and passes with it.origin/main.^startup_gfx2hlsl_dpp_(quad|pair): dev 12/12 and release 12/12 passed on this head.Commands executed:
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:16:48Z.
Code review location:
tools/startup/gfx2hlsl.py; line 3519In a branch-free pixel shader with entry WQM and a dead DPP pair read after an early
s_endpgm,decode()retains the suffix through the finals_endpgm, andnote_quad_flow()records the read becauseself.blocksis already nonempty. Bothbranchesandtargetsare empty, so this call raisesValueError. A synthetic program containing aquad_perm:[0,0,2,2]pair in that suffix emits HLSL on the parent but now crashes in both normal and refusal-collection mode. Guard the empty branch set or exclude unreachable reads before running the proof.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:19:39Z.
Code review location:
tools/startup/gfx2hlsl.py; line 3519Confirmed and fixed in
fc3afb5c0.quad_flow_refusalstookmin()of an empty branch and target list when a dead DPP read sits behind an earlys_endpgmin a branch-free program.min(..., default=inf). With nothing to precede, the rest of the proof (EXEC writers, uniform branches) still runs.tests/startup_gfx2hlsl_dpp_quad_flow_check.pygets a dead-read fixture. It fails on the previous head (exception) and passes now.Commands executed:
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T05:42:41Z.
Review: APPROVED
Reviewed the whole-quad flow proof and ran the new controls plus the existing DPP broadcast, swap and pair checks with main
e6902a11combined. The uniform loop matched all 256 pixels on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 (Windows 11 build 26200). The three wrong-lane mutations changed 256, 256 and 128 pixels respectively on each adapter. Missing WQM, a reaching EXEC write and unproved SCC flow stayed refused.Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T16:13:13Z.
Independent physical-GPU check of the merged
fc3afb5c0eb327edcbeb4d26eeeba60b75a3a9e3:python -B tests/startup_gfx2hlsl_dpp_quad_flow_check.py draw <dxc> <offscreen_check> <backend>matched all 256 pixels on both in-box WARP10.0.26100.10068and the physical RTX 407032.0.16.2124. Both caught the three wrong-lane mutations, which changed 256, 256 and 128 pixels. Translation/refusal controls passed as well. Windows26300.10075, SDK DXC1.9.2602.17, D3D12 debug layer enabled, zero errors or warnings, zero skips. I reused the Release offscreen runner after checking its pixel readback sources matched.