shader: extend pixel CMPX if/else read-only arms (Part of #3814) #3850
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3850"
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:33Z.
Part of #3814 (W7: ~130 pixel stages with two-armed CMPX if/else arms rejected by #3815).
Summary
Extends two-armed wave64 pixel CMPX if/else lowering in
pixel_readonly_arms(src/gfx1013_direct_graphics.inl, withtrace_symbolsfactored out ofparseinsrc/gfx1013_compute_native.cpp):Sopc, read-onlySmemdescriptor & scalar buffer loads, bound read-onlyMubufloads (buffer_load_dword,buffer_load_format), and explicit-LOD / explicit-gradient / query / gatherImageops (0, 1, 0x0e, 0x22, 0x24, 0x27, 0x2f, 0x47, 0x4f) inside either arm.s_or_b64 exec, exec, sPrestores, omitted ELSEs_cbranch_execzshortcuts, and nested straight-lines_and_saveexec_b64/s_mov_b64 + v_cmpx_inside either arm (inner_skips).trace_symbolsacross the lowered CFG edges to expire BOTH numeric SGPR/VCC/SCC values AND descriptor provenance atELSE,JOIN, and inner mask restores so no scalar or descriptor can leak across arms.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_w7_cmpx_ifelse_controls$': passed (21 validated DXIL modules + 53 strict refusals).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): 10 exact 8×2 draws + 26 exact mismatch controls 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:36Z.
Review: APPROVED
Reviewed
4b2b15d7(draft) by reading the diff and running an offline pixel census of this PR alone; not otherwise built or run.Verdict: approve. The widened two-armed CMPX arms keep every scalar and descriptor value local to its arm, and nested masks become real lane branches with phi joins. No MUST.
Census,
f365f125+ this PR alone, same capture as #3814 (6,436 pixel stages): 272 translate on both builds, none lost, but no stage changes its first refusal. In the W7 regions of that capture, the arms contain control flow thatpixel_armrefuses: a nesteds_mov_b64 sN, exec; v_cmpx; s_cbranch_execz(the inner CMPX has its own skip), or scalar branches inside the arm (s_and_b64 vcc, exec, sN; s_cbranch_vccnz, and ans_cbranch_scc0that leaves the region). SHOULD: a nested CMPX with an EXECZ skip to its own restore is the most common case. Accepting it, asinner_skipsalready does for the skip-free form, would reach real stages.gfx1013_direct_graphics.inl, mostly inpixel_readonly_arms. #3828 adds the sames_or_b64 exec, exec, sPrestore for one-armed skips.gfx1013_direct_graphics.inl:811,:827): 32-bit SALU and compares on data operands, read-only SMEM, boundbuffer_load_dword/_format, and images limited to load, load_mip, resinfo and explicit-LOD/gradient samples and gathers (0x22 0x24 0x27 0x2f 0x47 0x4f). EXEC reads, DPP, carries and branches are refused, as is a write to the parent or any open inner pair.s_mov_b64 sN, exec; v_cmpxors_and_saveexec_b64 sN, vccpaired with a restore ofsNin the same arm. Ingraphics_blocks(:1600), the mask block's successors are the inner restore and the next instruction, and the branch is emitted onsuccessors[0]/[1], so a lane outside the inner mask skips straight to the restore.trace_symbolsis re-run on the lowered edges with the sametransferargumentsparseused (:3223), so a descriptor identity cannot reach the join either.Tests:
_controls(21 modules, 53 refusals) is in theprfilter. The 10 draws and 26 mismatch controls per adapter ran only locally.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:26:18Z.
Review: APPROVED
Re-review on
73eb5280(rebased on5770f14e:s_or_b64restores for two arms, direct else without an EXECZ skip, nested masks inside an arm, waterfall descriptor recreated per image).Verdict: approve.
Census, same capture and method as before (6,436 distinct pixel stages), main
5770f14evs this head:Same as the earlier head: no W7 stage in this capture reaches the new shape first, so the fixtures carry the proof here.
Checked:
pixel_armadmits scalar work, local ALU,buffer_load_dword/formatand image loads or samples with explicit LOD, gradients or_lz(0x00, 0x01, 0x0e, 0x22, 0x24, 0x27, 0x2f, 0x47, 0x4f). No implicit-derivative sample can run with part of a quad switched off.false. Its restore is taken out of the standalone CMPXrestores, so it gets no second role in the CFG.trace_symbolsis a pure extraction fromparse.assigninstead ofresizeonly changes a second trace, which now starts clean.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T22:58:45Z.
Stacked on #3849 (and therefore on #3840). This branch includes their commits; please land them first.
36cf0675merges this PR onto #3849; the reviewed commit73eb5280is unchanged.58cb79e4fixes an interaction with #3849. With both merged, the nested CMPX control produced aselectwhere it needs a third lane branch. Proven read-only CMPX if/else arms are now recognized before masked arms, which restores the branch. The new nested draw matches all 16 pixels on WARP and the RTX 5080.6f6995e0adds regression coverage for the waterfall descriptor replay across CMPX joins that this PR already contained. Removing the descriptor invalidation makes the new control fail.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:02Z.
Merged the updated #3849 (main
f3ab02fe). The two shader conflicts keep W6's descriptor offset and bounds checks (#3839) alongside this PR's per-image descriptor replay. An added fixture case binds descriptor byte offsets 32 and 64 after a CMPX join, and refuses an undersized table. The pixel filter passed 55/55 in Debug and 55/55 in Release, with 0 skips. The PR preset passed 12/12. This PR is still stacked on #3849 and #3840.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T05:53:20Z.
Merged the updated #3849 (main
8a2f84d1, which includes #3840). This PR is now stacked on #3849 only. The graphics-lowering conflict keeps this PR's lowered branch successors, and requires the VCC shortcut to prove those edges before using them. The pixel filter passed 66/66 in Debug and 66/66 in Release, with 0 skips. The PR preset passed 2/2.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T06:29:49Z.
Independent verification at
c96063a8: MSVC Debug, Windows 11 build 26300, both compiler controls plus the two fixture families on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 passed (6/6, debug layer enabled, no skips). The skipped-path wrong-reference controls found the expected different pixel on both adapters.#3849 has now landed as
09ff8edec. The default merge of this stack conflicts indocs/experiments.mdandsrc/gfx1013_direct_graphics.inl. I verified thatgit merge-tree --write-tree --merge-base=13367a04 09ff8edec c96063a8is clean. Please replay only the delta from the final #3849 head13367a04ontomain; I can rerun the same tests on the updated head.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T07:17:13Z.
Thanks @R0Y00. As you suggested, I replayed only this PR's delta from the final #3849 head onto
main.33097f66is a merge ofc96063a8andmain29bb2aedwhose tree equalsgit merge-tree --merge-base=13367a04 29bb2aed c96063a8. The diff againstmainis exactly13367a04..c96063a8(7 files, +688/-73).native_pixel_|native_graphics_|native_direct_containerpassed 65/65 in Debug and 65/65 in Release, with 0 skips, including the #3849 masked-branch and W7 readbacks on WARP and the RTX 5080. The PR preset passed 3/3. No longer stacked, so this is marked Ready for review.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T07:31:01Z.
Review: APPROVED
Independently reviewed
33097f66. The stack delta applies cleanly on current main. Checked inner and outer saved-EXEC write guards, PHI joins, symbol tracing on the lowered edges, and descriptor replay across arm boundaries. MSVC Debug on Windows 11 build 26300: compiler and GPU tests for W7 CMPX if/else, masked branches, varying VCC branches and W6 waterfall passed 12/12. The GPU tests ran serially on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, with no capability skips. The skipped-path wrong-reference controls distinguished the expected pixels. Source-built fixtures only.