startup: lower DPP quad reads in pixel programs with uniform branches and loops (Part of #1723) #2705
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!2705
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2705/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-26 02:54 UTC · original
tedin7:x2w-dpp-quad-flow→main· +411 −6 · 4 files · 4 commits · merged 2026-11-26 05:42 UTCPart 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.
Symptom: a DPP16 quad read (quad swap, quad broadcast, pair broadcast) in a pixel program with any branch or loop was refused ("requires a straight-line pixel shader with entry EXEC" / "outside straight-line pixel code"), so every program that also has a loop failed even when the loop is a plain scalar counter. Root cause: the one-lane model runs each guest lane as its own HLSL thread through the pc dispatch, and the quad intrinsics only see a neighbour when the four threads of a quad reach them together. The old check required straight-line code instead of proving that. Change: Stage.quad_flow_refusals proves it over the whole program after translation: the s_wqm exec, exec runs before every branch and target, no other EXEC write can reach the read (CFG reachability, back edges included), and every conditional branch that can reach the read is wave-uniform (SCC proven uniform by the existing pass; execz/execnz under the whole-quad mask). vccz/vccnz loops, SCC from a lane mask, an EXEC write inside the loop and a late s_wqm are refused with the offset that breaks the proof. No wave size is assumed (SM 6.0 quad operations need only the 2x2 quad). Test: tests/startup_gfx2hlsl_dpp_quad_flow_check.py (controls fail before: LOOP refused, the four refusal reasons absent). Win2025 WARP (DXC ps_6_0) dev and release: LOOP draws 256/256 pixels equal to the CPU reference, the three wrong-lane mutations each fail; dpp_pair draws still pass. (cherry picked from commit 82d1b1d7786e8012494782d13eeefafd88b6a4c8)@tedin7 on GitHub · 2026-11-26 04:04 UTC · original
@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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 04:04 UTC · original · edited 2026-11-26 04:16 UTC
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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 04:16 UTC · original · reviewed
💡 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".
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 04:16 UTC · original
In 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 👍 / 👎.
@tedin7 on GitHub · 2026-11-26 04:19 UTC · original
Confirmed 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.
@tedin7 on GitHub · 2026-11-26 04:24 UTC · original
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.
@R0Y00 on GitHub · 2026-11-26 05:42 UTC · original · approved these changes
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.@RonLogic on GitHub · 2026-11-26 16:13 UTC · original
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.