shader: join pending loads at masked arm boundaries #1981
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1988"
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 avt0m4t48 on 2026-11-24T22:38:07Z.
Refs #987. Track pending loads at the start of each masked arm. When an arm can skip its wait, carry the outstanding loads from that arm's incoming state into the join. This covers a load issued in THEN whose wait can be skipped in ELSE, and avoids reinstating pending loads that an unconditional ELSE wait already resolved.
The old translator reproduced both errors with both region openers. The offline and LLVM 15 binary suites passed. Four source-built binaries round-tripped, and all eight variants that drop or delay the wait were rejected. DXC compiled the four generated pixel shaders. A local Vulkan compute wrapper around their emitted bodies used synthetic ramp samples and matched all 768 lane outputs on Lavapipe. Eight deliberately wrong mask cases mismatched.
The patch adds the fixtures to the existing WARP and hardware draw test route. Those D3D12 readbacks remain unverified here. Documentation links, bidi scan and
git diff --checkpassed. AI-assisted using Codex. Source-built inputs only.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:46:01Z.
Review: COMMENTED
Review of head
05ef4d9293.Result: 0 P1, 0 P2.
Reading: the masked if/else lowering now keeps the outstanding-load state per arm (
arm_outstanding). It is refreshed at the else transition and joined at the restore only when the last arm has a skip. The scc opener never carries a skip, because the skip target must match a saved exec pair, so dropping its state is safe. The change touches onlytools/pixel_aot.py,tests/pixel_aot_check.pyanddocs/experiments.md. No CMake change, no new dependency. The new code is a lowering fix with tests written from the ISA behaviour, so nothing is copied from elsewhere.Commands run locally:
git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflictspython3 tests/docs_links_check.py: PASS (18 files, 387 links)python3 tests/bidi_controls_check.py: PASSgit diff --check origin/main...HEAD: PASSpython3 -B tests/pixel_aot_check.py(full controls, Linux): PASSx2w_pipe.py win2025 1988,^pixel_aot_region_scalar_load_(warp|hardware)$): Debug 2/2 pass, Release /O2 2/2 pass,tests/pixel_aot_check.pyokMutations, each reverted with
git checkout -- .:if region["skip"] is not None:replaced byif False:). Killed bycheck_region_wait_controls.arm_outstandingrefresh at the else transition. Killed by the newcheck_region_else_wait_controls.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:46:56Z.
Ran it and broke the join four ways — all caught
Windows 11 build 26300.9974, device-free path:
Mutations to
tools/pixel_aot.py, each reverted:region.get("skipped")region["arm_outstanding"]arm_outstanding(always empty)arm_outstandingbut never use it (if False:)The third and fourth are the pair worth having: one breaks the data, the other keeps the data but drops the decision, and a fixture that only checked "the emitted HLSL compiles" would pass both. Yours fails both.
What the change is doing, restated so a reader can check me
The old code reinstated the region's pre-opener outstanding state after a skip, which is right when the whole region skipped and wrong when only the final arm skipped:
Moving the snapshot from the region to each arm is what fixes both symptoms in the description — a load issued in THEN whose wait is skipped in
ELSE now survives the join, and an ELSE that did wait unconditionally no longer has its resolved loads reinstated. Those are the same defect
seen from two directions, and the mutation table above exercises both because the join is the single place either can go wrong.
On the verification in the description
The eight deliberately wrong mask cases and the Lavapipe run (768 lane outputs) are the strongest part: a synthetic ramp through the emitted
bodies checks the values, not the text. I did not reproduce that here — no Vulkan wrapper in this environment — so what I can attest to is the
Python-level join behaviour and that the offline suite covers it.
The D3D12 readbacks added to the WARP and hardware routes did not run for me either (they need the draw route built); the description lists them
as unverified, which is accurate.
One question, not a defect
region["arm_outstanding"]is written at the end of every arm in the loop, including arms whose wait always ran. For those, the recorded stateequals the incoming state, so the join is a no-op — correct, but it means the name covers two meanings: "what this arm left outstanding" and
"what the join should carry". If that ever needs splitting, the unconditional-wait arm is the one to look at.
Verdict
Reviewed. Four independent ways to break the join, four failures; the value-level harness in the description covers what the text checks cannot.
Notes