shader: lower complementary pixel EXECZ arms inside whole-quad mode #3819
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3819"
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 Leyukaka on 2026-12-02T03:12:36Z.
Problem
The native pixel frontend refuses two shapes that a whole-quad-mode (WQM) pixel stage can legitimately contain.
It is refused with
graphics branch on a wave mask. Lowering the two skips as real branches would not be correct either: an implicit-LOD sample in an arm needs the coordinates of all four pixels of its quad, including lanes that are not in that arm.s_wqm_b64is refused withwhole-quad mode requires an unmodified pixel entry mask, although that move does not change EXEC.Change
Shader translation only, in
src/gfx1013_direct_graphics.inl. Two commits.shader: preserve quad inputs in complementary pixel EXECZ armsaddspixel_wqm_arms. When the region matches, both EXECZ skips are removed and the arms are if-converted:s_and_saveexec_b64 <coverage>/s_or_saveexec_b64window, with a fixed texture descriptor and a constant sampler. Its destination is updated only on covered lanes of its arm.The matcher is strict and falls back to the existing refusal on anything else:
s_wqm_b64must precede the region with no other EXEC write or branch before it;v_readfirstlaneand carry-writing scalars are not accepted in an arm;s_endpgm.Scalars written in the first arm are dropped at the inverse. Scalars written in either arm are dropped at the join.
shader: preserve WQM entry after primitive mask setupmoves the existing rule "s_mov_b32 m0, <proven primitive mask>needs no desktop equivalent" ahead of the pixel prologue check. No rule is added: the move was already accepted, but it ran after the check that marks the entry mask as modified. Loading any other value into M0, reading M0 afterwards, or writing a VGPR befores_wqm_b64is still refused.Related open work:
pixel_readonly_armsin the same file for a two-armed CMPX if/else whose join restores the saved pair, lowered with a per-lane branch. This PR covers a different shape (inside WQM, the join restores entry coverage, and the arms are flattened so implicit samples keep their quad) in a separate function. The behaviours do not overlap; a textual rebase may be needed depending on which lands first.Validation
Windows, MSVC.
compile_dxilneedsDXC_BIN_DIR.Both tests pass on the exact head of this PR.
New cases in
tests/native_direct_container_check.py:pixel-wqm-execz: the IR has nobr i1. The first-arm write is aselecton the compare, the second-arm write is aselecton the inverted compare ANDed with coverage, andisHelperLane,sampleLevelandsampleare all present.pixel-wqm-execz-scc: a fixed table record feeds a uniform SCC diamond in the second arm. The IR has exactly onebr i1, aphi, arawBufferLoadand the implicit sample.branch on a wave maskrefusal: wrong parent mask in the inverse, wrong coverage restore, wrong sample-window restore, coverage pair clobbered, WQM pair clobbered,v_readfirstlanein an arm, dynamic table offset, sample outside a window.New cases in
tests/native_fixed_graphics_psi1_check.py:wqm-primitive-m0compiles;wqm-numeric-m0,wqm-reads-m0andwqm-after-vector-writekeep their refusals.The fixtures are hand-assembled instruction words written for these tests.
Beyond the fixtures: in a run of a guest application, both refusals no longer appeared for the pixel pipelines that had them. That is a local observation. The public fixtures verify the lowering rules and the refusals listed above, not that run.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T03:25:43Z.
Review: APPROVED
Reviewed
0d1dad12by reading the diff; not built or run.Verdict: approve. The flattening matches the guest's WQM semantics, and the matcher fails closed on everything else. No MUST.
pixel-wqm-execzchecks only the IR shape (selects,isHelperLane,sample, nobr i1). A WARP draw with a gradient texture, a compare that splits quads, and an implicit sample in each arm would check it against a reference.pixel_wqm_armsreturns after the first match (gfx1013_direct_graphics.inl:721), so a stage with two such regions keeps the second one refused. A comment saying so, or acontinue, would make that explicit.:2455), with helper lanes included as under WQM. Only the sample window ANDs entry coverage (:2429), which matchess_and_saveexec_b64 <coverage>.pixel_readonly_armsruns first but cannot take this shape, because it needs the inverse and the restore to name the same pair and here they differ. The branch merges cleanly, and the CI run at this head started after #3815 merged.wqm-numeric-m0,-reads-m0and-after-vector-writekeep the refusals.Tests:
pixel-wqm-execzand-sccreach the new matcher and both lowering paths. The eight refusals each break one match condition. Neithernative_direct_containernornative_fixed_graphics_psi1matches theprpreset filter, so CI did not run them. Only the author's run at this head shows them passing.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T05:15:48Z.
Review: APPROVED
Independently rebuilt
compile_dxilon Windows Debug at0d1dad12.ctest --preset dev --no-tests=error -j 2 -R '^(native_direct_container|native_fixed_graphics_psi1)$' --output-on-failurepassed 2/2. This covers the complementary EXECZ and primitive-mask/WQM entry fixtures and their refusal controls. These checks exercise compiled shader output.