shader: lower structured branches in masked pixel regions (Part of #3814) #3849
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3849"
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 timbot103 on 2026-12-02T09:01:27Z.
Part of #3814 (
branch enters a masked graphics region, 363 stages +branch enters a CMPX region, 53 stages = 416 stages).Summary
Extends
GraphicsMaskRegionsandlower_graphicsinsrc/gfx1013_direct_graphics.inlto handle structured forward branches inside and around masked pixel regions:SAVEEXEC,s_and_b64, andv_cmpx_masked regions containing nested forward branches (nested SAVEEXEC, nested CMPX, or inner uniform scalar diamonds) using structured CFG lane branches (branch_saves/lane_branches/multimapbranch_merges) instead of failing straight-line flattening.restore.pcwhenexec_anchor+preserves_execproves the bypass edge already holds the parent EXEC mask (clearing inline CMPX predicates on the fallthrough predecessor before the join block so predicates never cross CFG edges).pixel_arms, implicit-LOD/DPP/LDS/stores/atomics, saved-EXEC clobbers, and escaped arm scalars/mask tags.Verification
compile_dxil,offscreen_check, andnative_pixel_ir_dumpin Debug (dev) and Release (release) with zero new C++20/W4warnings on edited lines.ctest --preset pr --no-tests=error --output-on-failure -R '^native_pixel_branch_masked_region_controls$': passed (22 DXIL validations + 21 refusal checks).dev) and Release (release): 14/14 passed in each build, zero skips.10.0.26100.9818) and NVIDIA GeForce RTX 5080 (32.0.16.2140) on Windows 11 (26200.9974): 22 exact 8×2 draws + 22 wrong-reference checks passed per build/adapter.tests/bidi_controls_check.py,tests/docs_links_check.py, andgit diff --check origin/main..HEADpassed.#3514's 5-PR ready cap.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T09:59:34Z.
Review: APPROVED
Reviewed
b8ec13a8(draft) by reading the diff (core paths in full, the rest spot-checked) and running an offline pixel census of this PR alone; not otherwise built or run.Verdict: approve. The structured lowering keeps every bypass edge tied to a proven parent EXEC, and every EXEC write or predicate that could cross an edge is refused. No MUST.
Census,
f365f125+ this PR alone, same capture as #3814 (6,436 pixel stages): 272 translate on both builds, none lost, no validation failures. 1,377 stages change their first refusal (1,137 fromgraphics branch on a wave mask, 144 frombranch enters a masked graphics region, 92 from lane-local arithmetic), but none reaches OK yet. Most (893) now stop atmasked pixel arm has an unsupported exit or memory effect, and in a 120-stage sample that is an implicit-LODimage_sample(54),ds_swizzle_b32(36) orimage_atomic_umin(30) inside the arm. Those are correct refusals, so this PR clears the region structure and exposes the next wall.exec_anchor(:604) needs a copy that dominates every entry up to the point (no edge from before it or backwards) andpreserves_execon every path. Only then may an outer branch land on a shared restore (pixel_restore_edge,:627). An EXECZ inside a proven arm becomesbr i1 false(:3286), which is sound because an invocation that reaches it in DXIL is in the guest EXEC.branch_mergesis now a multimap, andjoin_graphicsfolds every predicate at a pc into the control inputs (:1643), with a missing edge value ignored instead of throwing.mbcnt, stores and atomics are refused. Any EXEC write not recognised as a save, restore, complement, CMPX start or marker is refused (:1559). An inline CMPX predicate is cleared on the predecessor and refused if it reaches a block edge (:3273).:1160). The census above shows no stage that translated onmainis lost by it.preserves_execgains the wave32 copy/clobber rules and stops ats_endpgm, andwrexecclears EXEC knowledge.Tests:
_controls(22 validations, 21 refusals) is in theprfilter. The 22 draws with wrong-reference controls per adapter ran only locally.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T22:58:44Z.
Stacked on #3840. This branch includes #3840's commits; please land #3840 first.
f6a0b30emerges this PR onto #3840 as updated for main67862ee4; the reviewed commitf5ccad25is unchanged.2816e59dfixes an interaction with #3840's arm-local scalar writes. Two invalid shaders were accepted: one overwrote the inner saved EXEC pair, and one read a scalar after the inner arm ended. Nested and shared CMPX restores now validate the saved EXEC pair and expire arm-local scalar writes the same way the standalone path does. Both shapes now refuse with specific diagnostics, and two refusal fixtures cover them.Tests, Windows 11 26200 with RTX 5080 and WARP:
67862ee4, also passes its own three tests.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:40:00Z.
Merged
main(f3ab02fe) into this branch. The only conflict was the experiments index, where both entries are kept. It is still stacked on #3840, which is unchanged and Ready. The pixel filter passed 50/50 in Debug and 50/50 in Release, with 0 skips. The PR preset passed 9/9. A full Debug build of every target, including the C++17native_compute_pack_refusal_check, succeeded.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T05:53:16Z.
No longer stacked: #3840 has merged. Merged
main(8a2f84d1) into this branch. The resolution keeps main's #3840 fixture, compare-mask expiry and VCC skip handling alongside this PR's structured-arm and saved-EXEC checks. The diff againstmainnow contains only this PR's five files.native_pixel_|native_graphics_|native_direct_containerpassed 63/63 in Debug and 63/63 in Release, with 0 skips (23 WARP and 20 RTX 5080 tests per configuration). The PR preset passed 1/1, and a full Debug build including the C++17native_compute_pack_refusal_checksucceeded. Marked Ready for review, keeping within 5 non-draft PRs per #3514.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T06:28:35Z.
Review: APPROVED
Independently reviewed
13367a04. MSVC Debug on Windows 11 build 26300: branch_masked_region, masked_region_alu and varying_vcc_branch controls and GPU tests passed 9/9. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, debug layer enabled, zero skips. Inverting the structured CMPX comparison in a temporary build made nested-cmpx-flat fail on both backends (8 of 16 pixels differed). Removing either the local EXEC-preservation check or the structured-arm saved-EXEC overlap check in isolation was not distinguished by these controls. Source-built fixtures throughout.