shader: lower pixel alpha-test kills and coverage re-application #3829
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3829"
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:26:30Z.
Lowers wave64 pixel alpha-test
v_cmpx_*lane kills without a saved EXEC restore, post-interpolation coverage re-application (s_and_b64 exec, exec, sNin either operand order), and combined one-armed CMPX skips with coverage restore/re-application (items G1, G2, and W1 of #3814).Part of #3814. Refs #3640, #3641, #3703.
Summary
PixelLaneKillsinsrc/gfx1013_direct_graphics.inl):v_cmpx_*as a lane kill when the program is acyclic, no export precedes it, it dominates all code after it (no crossing branch orthen_fallthroughsedge, no earliers_endpgm), and all subsequent instructions are lane-local (no DPP/DPP8, LDS, quad compare, implicit-LOD sample, image store/atomic0x08..0x1f,quadmask,s_wqm, lane/mbcnt/store/sendmsg/barrier ops, non-buffer_atomic_addatomics,EXEC/EXECZreads outside recognized arm anchors, or non-narrowingEXECwrites outside restores from pairs saved strictly after the kill).dx.op.discard(!keep)in WQM, exact mode, or non-WQM, updatinglane_alive(andcovered/graphics_predicatewhen active) socovered_lane()explicitly ANDs in surviving lanes rather than relying on post-discardIsHelperLane.s_cbranch_execzskip (with only lane-local quiet ops between and no branch entering the span) to either a later instruction or a terminalEXP_NULLblock (droppingEXP_NULLonly when every branch targeting it is such a skip).s_and_b64 exec, exec, sN&enter_exact):enter_exact.s_and_b64 exec, exec, sN(both operand orders) whensNis proven entry coverage (invariant_entry_masksor tag"0"): leaves WQM in the prologue or in the unique post-dominating branch-free tail (exact_tail, disabled on any backward branch or earliers_endpgm), and acts as a no-op when already in exact mode or outside WQM.pixel_readonly_armsso a one-armed CMPX skip whose restore is the entry coverage saved immediately befores_wqm_b64 exec, execlowers its join viacoverage_restores->enter_exact.tests/native_pixel_alpha_kill_check.py+tests/cmake/native_pixel_alpha_kill.cmake:s_endpgm).Verification
Host: Windows 11 (
10.0.26200.9974), MSVC C++20/W4(zero new warnings), inbox WARP (10.0.26100.9818), NVIDIA GeForce RTX 5080 (32.0.16.2140).dev) & Release (release):native_pixel_alpha_kill_controls: passed in both configs (16 accepted + 16 refusals).native_pixel_alpha_kill_warp: passed in both configs (WARP readback + wrong-reference mismatch controls + all-killed draws).native_pixel_alpha_kill_hardware: passed in both configs (RTX 5080 readback + wrong-reference mismatch controls + all-killed draws).native_direct_container,native_pixel_dxil,native_graphics_wqm_{warp,hardware,ir},native_graphics_vertex_vcc_join_{warp,hardware},native_pixel_cmpx_{discard_warp,if_else_controls,if_else_warp},native_pixel_compare_mask_{warp,hardware,container,ir}.tests/bidi_controls_check.py,tests/docs_links_check.py,git diff --check origin/main..HEAD: all clean.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T07:35:03Z.
Review: APPROVED
Reviewed
b24a8d8aby reading the diff; not built or run.Verdict: approve. The discard matches the guest kill wherever
lane_local_afteraccepts the code after it. Every shape it ignores keeps its old refusal. No MUST.lane_local_afteracceptsbuffer_atomic_add(gfx1013_direct_graphics.inl:1508). Killed lanes skip it only becausecovered_lane()now ANDslane_alive(:2287), which the atomic uses as its predicate (:3193). One draw with a kill and then an atomic add, checking the count of surviving pixels only, would keep that from silently regressing.docs/experiments/mesh86-pixel-execz.mdsays about CMPX and coverage handling.ps86census onf365f125before and after would give the real gain. This can come in a follow-up._controls:native_pixel_alpha_kill_warpis not in theprpreset filter.pixel_readonly_arms. Two of them will need a rebase.saved_after), and so is an arm anchored before the kill, because the backward anchor search stops at the kill's EXEC write.exact_taillies after every branch andthen_fallthroughsedge, and is disabled by a backward branch or an earlys_endpgm.Tests:
_controlscompiles 16 shapes and 16 refusals (e.g. a restore that revives killed lanes)._warp/_hardwareread back with wrong-reference and all-killed controls. CI runs_controlsonly (in progress at review time).Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:17:28Z.
Census follow-up for the SHOULD in my review: on the #3814 capture, this PR does not yet move the G1 stages, because their kill uses a live-mask form that
lane_local_afterrefuses.graphics wave or control-flow instructionf365f125+ #3825Same capture and method as #3814. 6,436 distinct stages, run through
compile_dxil gfx1013-mesh86-ps. Counts only.In a 120-stage sample of the 648 that remain, 106 still stop at the
v_cmpx, and 105 of those have this shape (registers normalized):v_cmpxleaves EXEC holding the lanes to kill, not keep.s_andn2_b64removes them from the live masksK,scc0exits when no lane lives, ands_and_b64 exec, sC, sKrestores coverage AND live. Per invocation: keep = saved bit AND NOT compare, then discard where the compare holds. The fixtures' keep model (no live mask) would invert this shape.lane_local_afterrefuses the EXEC read ins_andn2_b64, so these stay refused, which is the safe outcome. Accepting this triple, withsKthe save made before thev_cmpx, would cover G1 + G2 for these stages.lane_local_afterdoes not depend on those two PRs, so the result should be the same here.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:33:19Z.
@lukaslw-lab Thanks for the approval and the exact census breakdown of the live-mask G1+G2 kill form (
s_mov_b64 sK, exec->v_cmpx_*->s_andn2_b64 sK, sK, exec->s_cbranch_scc0 L->s_and_b64 exec, sC, sK) — that is super actionable!To keep this approved PR clean and ready to land without restarting review, I will follow up in a dedicated PR (staged as Draft under #3514) adding:
v_cmpx_*+s_andn2_b64+s_cbranch_scc0+s_and_b64 exec, sC, sKkill/coverage-restore lowering (with keep =saved & ~cmpand discard wherecmpholds)buffer_atomic_adddocs/experiments/mesh86-pixel-execz.mdupdateImported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T10:09:47Z.
Review: COMMENTED
The reviewed revision now conflicts with main in the pixel mask state and one-arm matcher in
src/gfx1013_direct_graphics.inl. Please preserve #3826'sMaskOp/mask_inputschain handling alongside the newcoverage_restorespath. After rebasing, please run the alpha-kill andnative_pixel_saveexec_masks_families together so the coverage change and the existing compound-mask cases both have a readback.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T12:45:44Z.
Review: APPROVED
I re-reviewed
da0d37edon the current main base. The rebase keeps the compoundMaskOpchain and saved-pair clobber check. The new coverage restore is limited to the one-arm path withoutmerge_or, and the merge tree is clean.On Windows 11 26300.9974 (SDK 10.0.26100),
ctest --preset dev --no-tests=error -j 1 -V -R '^native_(pixel_alpha_kill_|pixel_saveexec_masks_|pixel_cmpx_if_else_controls$|graphics_wqm_ir$)'verified all eight selected tests with zero skips. Alpha-kill and compound SAVEEXEC readbacks and their wrong-reference controls passed on WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656. The renderer requests the D3D12 debug layer and successful draws' debug status is captured internally rather than printed by these Python fixtures. The WQM test initially lackednative_pixel_ir_dump; it passed after building that target and rerunning the same exact head.Required Windows CI still fails in
native_direct_meshwith+0x34: unmapped graphics export, tracked by #3851. Please rerun after the latter lands.