shader: lower waits and scalar loads in pixel_aot masked regions #1124
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1131"
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 tedin7 on 2026-11-24T01:37:10Z.
Change
Stage 3 of #987 (Refs #987). In
tools/pixel_aot.py, masked regions (s_and_saveexec_b64andv_cmpx_*openers) now admit:s_waitcntforms that resolve outstandingvmorlgkmwork. Waits ignore EXEC, so the wait runs for every wave that enters the region. For a region with thes_cbranch_execzskip, the restore puts back what was outstanding at the opener, so the first read after the region needs a wait outside it.s_load_dword{,x2,x4,x8}ands_buffer_load_dword{,x2,x4}(already lowered outside regions). Each is checked to change only its destinations, which become outstanding, and may not overwrite the saved execution pair. With the skip, the destinations become conditional like scalar ALU results.This replaces the earlier refusals (busy-counter wait, scalar load in a region).
docs/experiments.mdis updated and a new CTestpixel_aot_region_scalar_load_{warp,hardware}is registered.AI-assisted.
Verification
Linux, LLVM 19 (LLVM 15 packages are not available on this host):
python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so: the translation controls pass, including the newcheck_region_scalar_load_controlsand the rewrittencheck_region_wait_controls. The full binary run stops at a fixture unrelated to this change (v_cvt_f16_i16literal ands_version UC_VERSION_GFX7spelling differences with LLVM 19), so I ran the 12 region round-trip fixtures (including the 4 new ones, skip in label form) alone: all pass.tools/pixel_aot.pyfrom origin/main and the new tests, the controls fail at the first wait:Wait would resolve outstanding lgkm work in a masked region: s_waitcnt lgkmcnt(0). With the change they pass.Not run: the Windows draws (
draw-region-scalar-load, WARP and hardware) and the LLVM 15 CI job; they need Windows or the CI runner.Evidence and follow-up
The draw fixture is built from source. Its expected pixels come from the constants the test writes and the ramp (not from the translator); a reference with the writes on every lane and one with the wrong word of the two-dword load must mismatch on a precise word.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:24:44Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
4a76439d10ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:17:57Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
4a76439ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:27:57Z.
Fixed the P2 finding: a scalar load in a masked region that no wave can skip (no
s_cbranch_execz) now supersedes earlier conditional provenance of its destination SGPRs, both the region-local record and thescalar.conditionalset left by an earlier region. When the region can be skipped the conditionality is kept as before. New controls incheck_region_scalar_load_controlscover both reproductions from the finding under both openers: before the fix the first one fails with "Read of a register defined only on the masked path", after it both translate. Merged origin/main (no conflicts, no force). The local run reaches the unrelated LLVM 19 encoding checkcheck_f16_cvt_int16_binaryafter the region controls pass; CI uses LLVM 15. AI-assisted.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:24:44Z.
Code review location:
tools/pixel_aot.py; line 5187Without an
s_cbranch_execz, a scalar load defines its destination on every wave, but this block leaves earlier conditional-write tracking intact. A region containings_mov_b32 s72, 0, followed bys_buffer_load_dword s72, s[68:71], 0x20ands_waitcnt lgkmcnt(0), still leavess72inregion['scalar_written']; consequently, reading it after the restore is incorrectly rejected asdefined only on the masked path. Reloading an SGPR marked conditional by an earlier region similarly leavesscalar.conditionalset and rejects even an in-region read after the wait. Both cases reproduce under both openers. Clear superseded conditional provenance for loaded destinations, retaining restore-time conditionality only when the load can be skipped.Useful? React with 👍 / 👎.