shader: lower pixel SAVEEXEC lane-mask expressions (Part of #3814) #3826
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3826"
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-02T07:02:47Z.
Part of #3814. Refs #3640, #3641, #3703.
Lowers claimed #3814 pixel-stage items W3 (~370 stages) and W4 (~260 stages) in
src/gfx1013_direct_graphics.inl.Summary
v_cmp_* sM; s_and_b64 sM, vcc, sMrecognizer inpixel_readonly_armswith a recursive single-block proof (mask_source+straight_mask_chain) feedings_and_saveexec_b64 sP, sN(both one-armed skips and two-armed THEN/ELSE arms):s_xor_b64with inline-1(193) on either operand, ands_not_b64, fromvcc(106) or an SGPR compare pair.s_and_b64,s_or_b64, ands_andn2_b64(S0 & ~S1, operand order preserved) combining two proven lane masks in either operand order, writing either an aliased operand or a fresh even SGPR pair, chained up to depth 8.s_and_saveexec_b64 s[6:7], s[6:7](saving parent EXEC over the mask pair).v_cmp_*(noclass, SDWA, omod, clamp, DPP, or DPP8) within the same straight-line run (no branch, branch target, EXEC write/*exec*,v_div_scale,s_*pc_b64, ors_endpgmbetween earliest definition ands_and_saveexec_b64). (Note: VCC operands in these expressions are now strictly proven back to a plainv_cmp_*in the same straight-line run rather than accepting arbitrary reaching VCC.)s_xor_b64with1, a 32-bit literal, or-1on both operands; refuses odd pairs,vcc_hi, copied (s_mov_b64), unproven, or half-overwritten pairs.Verification (source-built fixtures only)
Environment: Windows 11 (
26200.9974), MSVC19.44(C++20/W4, zero new warnings), Ninja, Windows SDK10.0.26100.0, D3D12 debug layer unavailable.tests/native_pixel_saveexec_masks_check.py,tests/cmake/native_pixel_saveexec_masks.cmake) — Debug (dev) & Release (release):native_pixel_saveexec_masks_controls: 24 accepted shapes emit branch+merge DXIL with no wave ops; all 19 refusal controls refused.native_pixel_saveexec_masks_warp(Microsoft Basic Render Driver10.0.26100.9818): all 24 draws match; all inverted, operand-swapped, and single-arm negative references fail as expected.native_pixel_saveexec_masks_hardware(NVIDIA GeForce RTX 508032.0.16.2140): all 24 draws match (executed on GPU, not skipped).s_andn2_b64operands in the emitter failed WARP readback (8/16 pixels differed), confirming the GPU fixture pins operand order.native_direct_container,native_direct_mesh,native_pixel_dxil,native_pixel_cmpx_if_else_{controls,warp},native_pixel_cmpx_discard_warp,native_pixel_compare_mask_{warp,hardware,container},native_graphics_*).git diff --check origin/main..HEADclean.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T07:28:30Z.
Review: APPROVED
Reviewed
0eb75d25by reading the diff; not built or run.Verdict: approve. The mask expression lowering matches the guest semantics per invocation, and every gap I looked for fails closed. No MUST.
mask_sourcealso tightens the olds_and_b64 sM, vcc, sMpath: VCC must now reach a plainv_cmp_*in the same run, where it used to be read as-is. Aps86census before and after onf365f125would show the real gain and that no stage which translated on main is now refused. This can come in a follow-up._controls.native_pixel_saveexec_masks_warpis not in theprpreset filter, so the 24 draws and the operand-order references ran only locally.~,-(a & ~b, operand order kept) and|/&on the 0/1 bits (gfx1013_direct_graphics.inl:2457) matchs_not_b64,s_xor_b64 -1,s_andn2_b64,s_or_b64ands_and_b64for the invocation's own lane. Only inline-1(193) counts as an inversion, so a 32-bit literal is refused because it is not a pair register.v_cmpx_*: the decoder sets theirdstto 126, andwrites_pair(op,126)covers that.v_readlane/v_readfirstlaneand SMEM partial writes into the pair are caught byscalar_width, and VOP3Bv_div_scaleexplicitly.:2467), so any later numeric read of an intermediate pair fails closed.Tests:
_controlscompiles 24 shapes, checks the branch and merge DXIL, and refuses 19 controls. It reachesmask_source,straight_mask_chainand the new lowering._warp/_hardwarecheck each pixel's arm against inverted and operand-swapped references. CI ran_controls(green); WARP and hardware ran only in the author's local runs.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T07:34:52Z.
@lukaslw-lab Thanks for the thorough review and approval! Understood on the
ps86census before/afterf365f125to verify net stage gain and confirm no regression on the stricter VCCmask_sourcerule — happy to let that follow up separately.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T09:04:49Z.
Review: APPROVED
Independently built
compile_dxilandoffscreen_checkand ranctest --preset dev --no-tests=error -j 1 -R '^native_pixel_saveexec_masks_(controls|warp|hardware)$' --output-on-failure. All three passed (75.47 s, no skips) at0eb75d25on Windows 11 26300.9974 Debug, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. All 24 positive draw cases per backend matched, and the fixture rejected the incorrect arm references. The offscreen harness enables the installed D3D12 debug layer.