shader: extend pixel CMPX if/else read-only arms (Part of #3814) #3850

Merged
timbot103 merged 21 commits from upstream-pr/3850 into main 2026-12-03 07:31:06 +00:00
timbot103 commented 2026-12-02 09:01:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T09:01:33Z.


Part of #3814 (W7: ~130 pixel stages with two-armed CMPX if/else arms rejected by #3815).

Summary

Extends two-armed wave64 pixel CMPX if/else lowering in pixel_readonly_arms (src/gfx1013_direct_graphics.inl, with trace_symbols factored out of parse in src/gfx1013_compute_native.cpp):

  • Accepts safe 32-bit SALU, Sopc, read-only Smem descriptor & scalar buffer loads, bound read-only Mubuf loads (buffer_load_dword, buffer_load_format), and explicit-LOD / explicit-gradient / query / gather Image ops (0, 1, 0x0e, 0x22, 0x24, 0x27, 0x2f, 0x47, 0x4f) inside either arm.
  • Supports s_or_b64 exec, exec, sP restores, omitted ELSE s_cbranch_execz shortcuts, and nested straight-line s_and_saveexec_b64 / s_mov_b64 + v_cmpx_ inside either arm (inner_skips).
  • Re-runs trace_symbols across the lowered CFG edges to expire BOTH numeric SGPR/VCC/SCC values AND descriptor provenance at ELSE, JOIN, and inner mask restores so no scalar or descriptor can leak across arms.

Verification

  • Built compile_dxil, offscreen_check, and native_pixel_ir_dump in Debug (dev) and Release (release) with zero new C++20 /W4 warnings on edited lines.
  • ctest --preset pr --no-tests=error --output-on-failure -R '^native_pixel_w7_cmpx_ifelse_controls$': passed (21 validated DXIL modules + 53 strict refusals).
  • Debug (dev) and Release (release): 14/14 passed in each build, zero skips.
  • Real GPU readbacks on WARP (10.0.26100.9818) and NVIDIA GeForce RTX 5080 (32.0.16.2140) on Windows 11 (26200.9974): 10 exact 8×2 draws + 26 exact mismatch controls passed per build/adapter.
  • tests/bidi_controls_check.py, tests/docs_links_check.py, and git diff --check origin/main..HEAD passed.
  • Opened as Draft under #3514's 5-PR ready cap.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5603194154 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T09:01:33Z. --- Part of #3814 (W7: ~130 pixel stages with two-armed CMPX if/else arms rejected by #3815). ### Summary Extends two-armed wave64 pixel CMPX if/else lowering in `pixel_readonly_arms` (`src/gfx1013_direct_graphics.inl`, with `trace_symbols` factored out of `parse` in `src/gfx1013_compute_native.cpp`): - Accepts safe 32-bit SALU, `Sopc`, read-only `Smem` descriptor & scalar buffer loads, bound read-only `Mubuf` loads (`buffer_load_dword`, `buffer_load_format`), and explicit-LOD / explicit-gradient / query / gather `Image` ops (`0, 1, 0x0e, 0x22, 0x24, 0x27, 0x2f, 0x47, 0x4f`) inside either arm. - Supports `s_or_b64 exec, exec, sP` restores, omitted ELSE `s_cbranch_execz` shortcuts, and nested straight-line `s_and_saveexec_b64` / `s_mov_b64 + v_cmpx_` inside either arm (`inner_skips`). - Re-runs `trace_symbols` across the lowered CFG edges to expire BOTH numeric SGPR/VCC/SCC values AND descriptor provenance at `ELSE`, `JOIN`, and inner mask restores so no scalar or descriptor can leak across arms. ### Verification - Built `compile_dxil`, `offscreen_check`, and `native_pixel_ir_dump` in Debug (`dev`) and Release (`release`) with zero new C++20 `/W4` warnings on edited lines. - `ctest --preset pr --no-tests=error --output-on-failure -R '^native_pixel_w7_cmpx_ifelse_controls$'`: passed (**21 validated DXIL modules + 53 strict refusals**). - Debug (`dev`) and Release (`release`): 14/14 passed in each build, zero skips. - Real GPU readbacks on WARP (`10.0.26100.9818`) and NVIDIA GeForce RTX 5080 (`32.0.16.2140`) on Windows 11 (`26200.9974`): **10 exact 8×2 draws + 26 exact mismatch controls** passed per build/adapter. - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, and `git diff --check origin/main..HEAD` passed. - Opened as Draft under `#3514`'s 5-PR ready cap.
lukaslw-lab commented 2026-12-02 09:59:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T09:59:36Z.

Review: APPROVED


Reviewed 4b2b15d7 (draft) by reading the diff and running an offline pixel census of this PR alone; not otherwise built or run.

Verdict: approve. The widened two-armed CMPX arms keep every scalar and descriptor value local to its arm, and nested masks become real lane branches with phi joins. No MUST.

Census, f365f125 + this PR alone, same capture as #3814 (6,436 pixel stages): 272 translate on both builds, none lost, but no stage changes its first refusal. In the W7 regions of that capture, the arms contain control flow that pixel_arm refuses: a nested s_mov_b64 sN, exec; v_cmpx; s_cbranch_execz (the inner CMPX has its own skip), or scalar branches inside the arm (s_and_b64 vcc, exec, sN; s_cbranch_vccnz, and an s_cbranch_scc0 that leaves the region). SHOULD: a nested CMPX with an EXECZ skip to its own restore is the most common case. Accepting it, as inner_skips already does for the skip-free form, would reach real stages.

  • NIT This conflicts with #3828, #3845, #3847, #3848 and #3849 in gfx1013_direct_graphics.inl, mostly in pixel_readonly_arms. #3828 adds the same s_or_b64 exec, exec, sP restore for one-armed skips.
  • Checked, no finding:
    • Arm contents (gfx1013_direct_graphics.inl:811, :827): 32-bit SALU and compares on data operands, read-only SMEM, bound buffer_load_dword/_format, and images limited to load, load_mip, resinfo and explicit-LOD/gradient samples and gathers (0x22 0x24 0x27 0x2f 0x47 0x4f). EXEC reads, DPP, carries and branches are refused, as is a write to the parent or any open inner pair.
    • Inner masks: only s_mov_b64 sN, exec; v_cmpx or s_and_saveexec_b64 sN, vcc paired with a restore of sN in the same arm. In graphics_blocks (:1600), the mask block's successors are the inner restore and the next instruction, and the branch is emitted on successors[0]/[1], so a lane outside the inner mask skips straight to the restore.
    • Expiry and provenance: then-arm writes expire at ELSE, both arms' writes at the join, and inner writes plus the saved pair at the inner restore. trace_symbols is re-run on the lowered edges with the same transfer arguments parse used (:3223), so a descriptor identity cannot reach the join either.

Tests: _controls (21 modules, 53 refusals) is in the pr filter. The 10 draws and 26 mismatch controls per adapter ran only locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6148570583 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#pullrequestreview-6148570583). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T09:59:36Z. **Review:** APPROVED --- Reviewed `4b2b15d7` (draft) by reading the diff and running an offline pixel census of this PR alone; not otherwise built or run. **Verdict: approve.** The widened two-armed CMPX arms keep every scalar and descriptor value local to its arm, and nested masks become real lane branches with phi joins. No MUST. Census, `f365f125` + this PR alone, same capture as #3814 (6,436 pixel stages): 272 translate on both builds, **none lost**, but **no stage changes its first refusal**. In the W7 regions of that capture, the arms contain control flow that `pixel_arm` refuses: a nested `s_mov_b64 sN, exec; v_cmpx; s_cbranch_execz` (the inner CMPX has its own skip), or scalar branches inside the arm (`s_and_b64 vcc, exec, sN; s_cbranch_vccnz`, and an `s_cbranch_scc0` that leaves the region). **SHOULD:** a nested CMPX with an EXECZ skip to its own restore is the most common case. Accepting it, as `inner_skips` already does for the skip-free form, would reach real stages. - **NIT** This conflicts with #3828, #3845, #3847, #3848 and #3849 in `gfx1013_direct_graphics.inl`, mostly in `pixel_readonly_arms`. #3828 adds the same `s_or_b64 exec, exec, sP` restore for one-armed skips. - Checked, no finding: - Arm contents (`gfx1013_direct_graphics.inl:811`, `:827`): 32-bit SALU and compares on data operands, read-only SMEM, bound `buffer_load_dword`/`_format`, and images limited to load, load_mip, resinfo and explicit-LOD/gradient samples and gathers (`0x22 0x24 0x27 0x2f 0x47 0x4f`). EXEC reads, DPP, carries and branches are refused, as is a write to the parent or any open inner pair. - Inner masks: only `s_mov_b64 sN, exec; v_cmpx` or `s_and_saveexec_b64 sN, vcc` paired with a restore of `sN` in the same arm. In `graphics_blocks` (`:1600`), the mask block's successors are the inner restore and the next instruction, and the branch is emitted on `successors[0]/[1]`, so a lane outside the inner mask skips straight to the restore. - Expiry and provenance: then-arm writes expire at ELSE, both arms' writes at the join, and inner writes plus the saved pair at the inner restore. `trace_symbols` is re-run on the lowered edges with the same `transfer` arguments `parse` used (`:3223`), so a descriptor identity cannot reach the join either. Tests: `_controls` (21 modules, 53 refusals) is in the `pr` filter. The 10 draws and 26 mismatch controls per adapter ran only locally.
lukaslw-lab commented 2026-12-02 20:26:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:26:18Z.

Review: APPROVED


Re-review on 73eb5280 (rebased on 5770f14e: s_or_b64 restores for two arms, direct else without an EXECZ skip, nested masks inside an arm, waterfall descriptor recreated per image).

Verdict: approve.

Census, same capture and method as before (6,436 distinct pixel stages), main 5770f14e vs this head:

Stages
Translate, main / with this PR 272 / 272
Lost / gained / first refusal moved 0 / 0 / 0

Same as the earlier head: no W7 stage in this capture reaches the new shape first, so the fixtures carry the proof here.

Checked:

  • pixel_arm admits scalar work, local ALU, buffer_load_dword/format and image loads or samples with explicit LOD, gradients or _lz (0x00, 0x01, 0x0e, 0x22, 0x24, 0x27, 0x2f, 0x47, 0x4f). No implicit-derivative sample can run with part of a quad switched off.
  • A nested save must be followed directly by its CMPX, with no EXEC read, and an empty inner arm returns false. Its restore is taken out of the standalone CMPX restores, so it gets no second role in the CFG.
  • The parent pair and every open inner pair are checked for overwrites, and arm writes expire at the inverse and at the restore.
  • trace_symbols is a pure extraction from parse. assign instead of resize only changes a second trace, which now starts clean.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158358447 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#pullrequestreview-6158358447). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T20:26:18Z. **Review:** APPROVED --- Re-review on `73eb5280` (rebased on `5770f14e`: `s_or_b64` restores for two arms, direct else without an EXECZ skip, nested masks inside an arm, waterfall descriptor recreated per image). **Verdict: approve.** Census, same capture and method as before (6,436 distinct pixel stages), main `5770f14e` vs this head: | | Stages | |---|---:| | Translate, main / with this PR | 272 / 272 | | Lost / gained / first refusal moved | 0 / 0 / 0 | Same as the earlier head: no W7 stage in this capture reaches the new shape first, so the fixtures carry the proof here. Checked: - `pixel_arm` admits scalar work, local ALU, `buffer_load_dword`/`format` and image loads or samples with explicit LOD, gradients or `_lz` (0x00, 0x01, 0x0e, 0x22, 0x24, 0x27, 0x2f, 0x47, 0x4f). No implicit-derivative sample can run with part of a quad switched off. - A nested save must be followed directly by its CMPX, with no EXEC read, and an empty inner arm returns `false`. Its restore is taken out of the standalone CMPX `restores`, so it gets no second role in the CFG. - The parent pair and every open inner pair are checked for overwrites, and arm writes expire at the inverse and at the restore. - `trace_symbols` is a pure extraction from `parse`. `assign` instead of `resize` only changes a second trace, which now starts clean. AI-assisted.
timbot103 commented 2026-12-02 22:58:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T22:58:45Z.


Stacked on #3849 (and therefore on #3840). This branch includes their commits; please land them first.

  • 36cf0675 merges this PR onto #3849; the reviewed commit 73eb5280 is unchanged.
  • 58cb79e4 fixes an interaction with #3849. With both merged, the nested CMPX control produced a select where it needs a third lane branch. Proven read-only CMPX if/else arms are now recognized before masked arms, which restores the branch. The new nested draw matches all 16 pixels on WARP and the RTX 5080.
  • 6f6995e0 adds regression coverage for the waterfall descriptor replay across CMPX joins that this PR already contained. Removing the descriptor invalidation makes the new control fail.

Tests, Windows 11 26200 with RTX 5080 and WARP:

  • The pixel filter passed 47/47 in Debug and 47/47 in Release.
  • The PR preset passed 12/12.
  • This PR alone, merged onto 67862ee4, also passes its own three tests.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7361406560 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#issuecomment-7361406560). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T22:58:45Z. --- **Stacked on #3849** (and therefore on #3840). This branch includes their commits; please land them first. - `36cf0675` merges this PR onto #3849; the reviewed commit `73eb5280` is unchanged. - `58cb79e4` fixes an interaction with #3849. With both merged, the nested CMPX control produced a `select` where it needs a third lane branch. Proven read-only CMPX if/else arms are now recognized before masked arms, which restores the branch. The new nested draw matches all 16 pixels on WARP and the RTX 5080. - `6f6995e0` adds regression coverage for the waterfall descriptor replay across CMPX joins that this PR already contained. Removing the descriptor invalidation makes the new control fail. Tests, Windows 11 26200 with RTX 5080 and WARP: - The pixel filter passed 47/47 in Debug and 47/47 in Release. - The PR preset passed 12/12. - This PR alone, merged onto `67862ee4`, also passes its own three tests.
timbot103 commented 2026-12-03 01:40:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:40:02Z.


Merged the updated #3849 (main f3ab02fe). The two shader conflicts keep W6's descriptor offset and bounds checks (#3839) alongside this PR's per-image descriptor replay. An added fixture case binds descriptor byte offsets 32 and 64 after a CMPX join, and refuses an undersized table. The pixel filter passed 55/55 in Debug and 55/55 in Release, with 0 skips. The PR preset passed 12/12. This PR is still stacked on #3849 and #3840.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7364598795 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#issuecomment-7364598795). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T01:40:02Z. --- Merged the updated #3849 (main `f3ab02fe`). The two shader conflicts keep W6's descriptor offset and bounds checks (#3839) alongside this PR's per-image descriptor replay. An added fixture case binds descriptor byte offsets 32 and 64 after a CMPX join, and refuses an undersized table. The pixel filter passed 55/55 in Debug and 55/55 in Release, with 0 skips. The PR preset passed 12/12. This PR is still stacked on #3849 and #3840.
timbot103 commented 2026-12-03 05:53:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T05:53:20Z.


Merged the updated #3849 (main 8a2f84d1, which includes #3840). This PR is now stacked on #3849 only. The graphics-lowering conflict keeps this PR's lowered branch successors, and requires the VCC shortcut to prove those edges before using them. The pixel filter passed 66/66 in Debug and 66/66 in Release, with 0 skips. The PR preset passed 2/2.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7369222575 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#issuecomment-7369222575). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T05:53:20Z. --- Merged the updated #3849 (main `8a2f84d1`, which includes #3840). This PR is now stacked on #3849 only. The graphics-lowering conflict keeps this PR's lowered branch successors, and requires the VCC shortcut to prove those edges before using them. The pixel filter passed 66/66 in Debug and 66/66 in Release, with 0 skips. The PR preset passed 2/2.
R0Y00 commented 2026-12-03 06:29:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T06:29:49Z.


Independent verification at c96063a8: MSVC Debug, Windows 11 build 26300, both compiler controls plus the two fixture families on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 passed (6/6, debug layer enabled, no skips). The skipped-path wrong-reference controls found the expected different pixel on both adapters.

#3849 has now landed as 09ff8edec. The default merge of this stack conflicts in docs/experiments.md and src/gfx1013_direct_graphics.inl. I verified that git merge-tree --write-tree --merge-base=13367a04 09ff8edec c96063a8 is clean. Please replay only the delta from the final #3849 head 13367a04 onto main; I can rerun the same tests on the updated head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7369900228 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#issuecomment-7369900228). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T06:29:49Z. --- Independent verification at `c96063a8`: MSVC Debug, Windows 11 build 26300, both compiler controls plus the two fixture families on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 passed (6/6, debug layer enabled, no skips). The skipped-path wrong-reference controls found the expected different pixel on both adapters. #3849 has now landed as `09ff8edec`. The default merge of this stack conflicts in `docs/experiments.md` and `src/gfx1013_direct_graphics.inl`. I verified that `git merge-tree --write-tree --merge-base=13367a04 09ff8edec c96063a8` is clean. Please replay only the delta from the final #3849 head `13367a04` onto `main`; I can rerun the same tests on the updated head.
timbot103 commented 2026-12-03 07:17:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T07:17:13Z.


Thanks @R0Y00. As you suggested, I replayed only this PR's delta from the final #3849 head onto main. 33097f66 is a merge of c96063a8 and main 29bb2aed whose tree equals git merge-tree --merge-base=13367a04 29bb2aed c96063a8. The diff against main is exactly 13367a04..c96063a8 (7 files, +688/-73). native_pixel_|native_graphics_|native_direct_container passed 65/65 in Debug and 65/65 in Release, with 0 skips, including the #3849 masked-branch and W7 readbacks on WARP and the RTX 5080. The PR preset passed 3/3. No longer stacked, so this is marked Ready for review.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7370814914 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#issuecomment-7370814914). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T07:17:13Z. --- Thanks @R0Y00. As you suggested, I replayed only this PR's delta from the final #3849 head onto `main`. `33097f66` is a merge of `c96063a8` and `main` `29bb2aed` whose tree equals `git merge-tree --merge-base=13367a04 29bb2aed c96063a8`. The diff against `main` is exactly `13367a04..c96063a8` (7 files, +688/-73). `native_pixel_|native_graphics_|native_direct_container` passed 65/65 in Debug and 65/65 in Release, with 0 skips, including the #3849 masked-branch and W7 readbacks on WARP and the RTX 5080. The PR preset passed 3/3. No longer stacked, so this is marked Ready for review.
R0Y00 commented 2026-12-03 07:31:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T07:31:01Z.

Review: APPROVED


Independently reviewed 33097f66. The stack delta applies cleanly on current main. Checked inner and outer saved-EXEC write guards, PHI joins, symbol tracing on the lowered edges, and descriptor replay across arm boundaries. MSVC Debug on Windows 11 build 26300: compiler and GPU tests for W7 CMPX if/else, masked branches, varying VCC branches and W6 waterfall passed 12/12. The GPU tests ran serially on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, with no capability skips. The skipped-path wrong-reference controls distinguished the expected pixels. Source-built fixtures only.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6165398249 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3850#pullrequestreview-6165398249). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T07:31:01Z. **Review:** APPROVED --- Independently reviewed 33097f66. The stack delta applies cleanly on current main. Checked inner and outer saved-EXEC write guards, PHI joins, symbol tracing on the lowered edges, and descriptor replay across arm boundaries. MSVC Debug on Windows 11 build 26300: compiler and GPU tests for W7 CMPX if/else, masked branches, varying VCC branches and W6 waterfall passed 12/12. The GPU tests ran serially on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, with no capability skips. The skipped-path wrong-reference controls distinguished the expected pixels. Source-built fixtures only.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3850
No description provided.