shader: lower single forward exec-masked regions in pixel_aot #645

Merged
MarlomMedeiros merged 3 commits from upstream-pr/651 into main 2026-11-23 13:26:13 +00:00
MarlomMedeiros commented 2026-11-22 17:39:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T17:39:50Z.


Refs #338. Implements option A: a single forward masked-if region lowered
to per-lane selects, keeping the straight-line API for plain instruction
lists while branch-bearing programs arrive as (offset, text) pairs.

Summary

  • s_and_saveexec_b64 s[..], vcc|s[..] after a tracked v_cmp opens a
    region: the old EXEC mask is saved into an even SGPR pair and the
    condition applies as the new mask. s_or_b64 exec, exec, s[..] closes
    it. An optional adjacent s_cbranch_execz may skip to the matching
    restore, with the displacement validated as a signed 16-bit value
    landing on an exact instruction boundary.
  • Only pure per-lane vector ops run inside a region: a state snapshot
    around each instruction rejects any scalar, memory, sampling,
    interpolation, export, wait, EXEC-affecting, cross-lane or DPP side
    effect, and REGION_DENIED filters the instruction shapes up front.
  • Modified VGPRs merge as precise float aluN_dst = (cond ? inner : outer).
    Registers first written inside are marked conditional; post-merge reads
    of a path-undefined value reject until an unconditional write.
  • The saved pair is protected from reuse, SCC tracking is cleared across
    save/restore, and nesting, second skips, invalid mask sources,
    wrong-pair or later same-pair restore targets all reject cleanly.

Tests

  • Synthetic fixtures cover mixed/full/empty masks at thresholds 0.5, 10
    and -1, complementary sequential regions, and the skip variant both as
    offset pairs and as a real label-based program round-tripped through
    llvm-mc and the LLVM 15 disassembler.
  • GPU draw fixtures run on WARP and on hardware: 9 masked cases pass,
    and reversed-predicate plus mask-free mutants mismatch on both
    adapters. Negative controls cover every rejection path.
  • tests/pixel_aot_check.py, form_coverage_check.py,
    docs_links_check.py, bidi_controls_check.py all pass.

Evidence

  • ctest --preset dev -R '^pixel_aot_warp$' -V: pass on
    1f16321/9179318, Windows 11 build 26300.10075, zero debug errors.
  • ctest --preset dev -R '^pixel_aot_hardware$' -V: pass, GeForce RTX
    5070, driver 32.0.16.2135, D3D12 debug layer enabled.
  • LLVM 15.0.7 binary round-trip: tests/pixel_aot_check.py binary pass.

AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6545568175 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/651). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-22T17:39:50Z. --- Refs #338. Implements option A: a single forward masked-if region lowered to per-lane selects, keeping the straight-line API for plain instruction lists while branch-bearing programs arrive as (offset, text) pairs. ## Summary - `s_and_saveexec_b64 s[..], vcc|s[..]` after a tracked `v_cmp` opens a region: the old EXEC mask is saved into an even SGPR pair and the condition applies as the new mask. `s_or_b64 exec, exec, s[..]` closes it. An optional adjacent `s_cbranch_execz` may skip to the matching restore, with the displacement validated as a signed 16-bit value landing on an exact instruction boundary. - Only pure per-lane vector ops run inside a region: a state snapshot around each instruction rejects any scalar, memory, sampling, interpolation, export, wait, EXEC-affecting, cross-lane or DPP side effect, and REGION_DENIED filters the instruction shapes up front. - Modified VGPRs merge as `precise float aluN_dst = (cond ? inner : outer)`. Registers first written inside are marked conditional; post-merge reads of a path-undefined value reject until an unconditional write. - The saved pair is protected from reuse, SCC tracking is cleared across save/restore, and nesting, second skips, invalid mask sources, wrong-pair or later same-pair restore targets all reject cleanly. ## Tests - Synthetic fixtures cover mixed/full/empty masks at thresholds 0.5, 10 and -1, complementary sequential regions, and the skip variant both as offset pairs and as a real label-based program round-tripped through llvm-mc and the LLVM 15 disassembler. - GPU draw fixtures run on WARP and on hardware: 9 masked cases pass, and reversed-predicate plus mask-free mutants mismatch on both adapters. Negative controls cover every rejection path. - `tests/pixel_aot_check.py`, `form_coverage_check.py`, `docs_links_check.py`, `bidi_controls_check.py` all pass. ## Evidence - `ctest --preset dev -R '^pixel_aot_warp$' -V`: pass on `1f16321`/`9179318`, Windows 11 build 26300.10075, zero debug errors. - `ctest --preset dev -R '^pixel_aot_hardware$' -V`: pass, GeForce RTX 5070, driver 32.0.16.2135, D3D12 debug layer enabled. - LLVM 15.0.7 binary round-trip: `tests/pixel_aot_check.py binary` pass. AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.
upstream-sync closed this pull request 2026-11-24 06:44:09 +00:00
copilot-pull-request-reviewer[bot commented 2026-11-24 06:44:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-22T17:39:58Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6013549492 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/651#pullrequestreview-6013549492). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-22T17:39:58Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
rwZephyr commented 2026-11-24 06:48:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rwZephyr on 2026-11-22T18:54:40Z.


Independent Windows 10 run on 1a252c8162df82a8f28ed19605e994b7a8529bfe. Windows 10 22H2 build 19045.6466, MSVC 19.44.35230, Windows SDK 10.0.26100.0, DXC 1.8.2502.11. D3D12 debug layer unavailable on both backends.

cmake --preset dev "-DINTAKE_PYTHON=$((Get-Command python).Source)" "-DDXC_EXECUTABLE=$dxc" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
cmake --build --preset dev --parallel 4 --target offscreen_check
$env:XBOX2WINDOWS_ADAPTER = 'RTX 3060 Ti'
ctest --preset dev --no-tests=error -V -R '^pixel_aot_(hardware|warp)$'
  • Hardware: RTX 3060 Ti (10de:2414), driver 621.24 (32.0.16.2124 via DXGI). Full suite passed.
  • Software: In-box WARP (1414:008c), driver 10.0.19041.5794. Full suite passed.
  • Skipped: Zero.

I also ran check_masked_draw directly on both backends. The forward region, empty-mask skip, and complementary regions each matched the reference at thresholds 0.5, 10.0, and -1.0. All nine draws matched all 4,096 pixels with zero absolute error. The reversed predicate and removed mask produced the expected first mismatches at (0, 0) and (40, 0), respectively, on both adapters.

The base translator at 7009a7e rejected the same forward-region program at s_and_saveexec_b64, so the base comparison ended before rendering.

AI-assisted. All reported tests ran locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7083962168 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/651#issuecomment-7083962168). Originally posted by [rwZephyr](https://github.com/rwZephyr) on 2026-11-22T18:54:40Z. --- Independent Windows 10 run on `1a252c8162df82a8f28ed19605e994b7a8529bfe`. Windows 10 22H2 build `19045.6466`, MSVC `19.44.35230`, Windows SDK `10.0.26100.0`, DXC `1.8.2502.11`. D3D12 debug layer unavailable on both backends. ```powershell cmake --preset dev "-DINTAKE_PYTHON=$((Get-Command python).Source)" "-DDXC_EXECUTABLE=$dxc" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug cmake --build --preset dev --parallel 4 --target offscreen_check $env:XBOX2WINDOWS_ADAPTER = 'RTX 3060 Ti' ctest --preset dev --no-tests=error -V -R '^pixel_aot_(hardware|warp)$' ``` - **Hardware:** RTX 3060 Ti (`10de:2414`), driver `621.24` (`32.0.16.2124` via DXGI). Full suite passed. - **Software:** In-box WARP (`1414:008c`), driver `10.0.19041.5794`. Full suite passed. - **Skipped:** Zero. I also ran `check_masked_draw` directly on both backends. The forward region, empty-mask skip, and complementary regions each matched the reference at thresholds `0.5`, `10.0`, and `-1.0`. All nine draws matched all 4,096 pixels with zero absolute error. The reversed predicate and removed mask produced the expected first mismatches at `(0, 0)` and `(40, 0)`, respectively, on both adapters. The base translator at `7009a7e` rejected the same forward-region program at `s_and_saveexec_b64`, so the base comparison ended before rendering. AI-assisted. All reported tests ran locally.
MarlomMedeiros commented 2026-11-24 06:48:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T19:16:10Z.


Thanks for the independent run, @rwZephyr — that's a nice complementary data point: RTX 3060 Ti + Windows 10 + in-box WARP 10.0.19041.5794 on your side, RTX 5070 + Windows 11 + WARP 10.0.26100.10068 on ours, so the masked-region draws and the (0,0)/(40,0) negative-control first mismatches now hold on two NVIDIA generations, two OS builds, and two WARP versions. The s_and_saveexec_b64 rejection on base 7009a7e also confirms the program only renders through the new region lowering.

AI-assisted: yes. All reported checks ran locally on the adapter and driver listed in the PR body.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084253806 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/651#issuecomment-7084253806). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-22T19:16:10Z. --- Thanks for the independent run, @rwZephyr — that's a nice complementary data point: RTX 3060 Ti + Windows 10 + in-box WARP `10.0.19041.5794` on your side, RTX 5070 + Windows 11 + WARP `10.0.26100.10068` on ours, so the masked-region draws and the `(0,0)`/`(40,0)` negative-control first mismatches now hold on two NVIDIA generations, two OS builds, and two WARP versions. The `s_and_saveexec_b64` rejection on base `7009a7e` also confirms the program only renders through the new region lowering. AI-assisted: yes. All reported checks ran locally on the adapter and driver listed in the PR body.
rasptum commented 2026-11-24 06:48:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-22T19:50:02Z.


Independent Windows 10 run on 1a252c8162df82a8f28ed19605e994b7a8529bfe (PR head).

Windows 10 Pro 22H2 (10.0.19045), D3D12 debug layer enabled. Built with the dev preset and the default SDK DXC.

.\tools\dev.ps1
cmake --preset dev
cmake --build --preset dev --parallel 8
ctest --preset dev --no-tests=error -V -R '^pixel_aot_(warp|hardware)$'
  • Hardware: pixel_aot_hardware passed on NVIDIA GeForce RTX 3060 (10de:2503), driver 32.0.15.9636. Debug errors 0, debug warnings 0. Every reported draw had max_absolute_error=0 (49 result lines at zero error).
  • Software: pixel_aot_warp passed on Microsoft Basic Render Driver (in-box WARP, 1414:008c), driver 10.0.19041.5794. Debug errors 0, debug warnings 0.
  • Masked-draw mutants: the reversed and unmasked mutants are checked inside both GPU tests and must return mismatch on each adapter. Both held on WARP and on hardware, and the 9 masked cases (3 programs at thresholds 0.5, 10 and -1) passed.
  • Python checks: tests/pixel_aot_check.py, tests/form_coverage_check.py, tests/docs_links_check.py (126 links) and tests/bidi_controls_check.py all exit 0.
  • LLVM 15 binary round trip: tests/pixel_aot_check.py binary with LLVM 15.0.7 (llvm-objcopy, LLVM-C.dll) exits 0.
  • Skipped: None of the GPU tests.

This comment only covers the Windows 10 box above. The Win11 / RTX 5070 run from the PR body was not repeated.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084711757 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/651#issuecomment-7084711757). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-22T19:50:02Z. --- Independent Windows 10 run on `1a252c8162df82a8f28ed19605e994b7a8529bfe` (PR head). Windows 10 Pro 22H2 (`10.0.19045`), D3D12 debug layer enabled. Built with the dev preset and the default SDK DXC. ```powershell .\tools\dev.ps1 cmake --preset dev cmake --build --preset dev --parallel 8 ctest --preset dev --no-tests=error -V -R '^pixel_aot_(warp|hardware)$' ``` - **Hardware:** `pixel_aot_hardware` passed on NVIDIA GeForce RTX 3060 (`10de:2503`), driver `32.0.15.9636`. Debug errors 0, debug warnings 0. Every reported draw had `max_absolute_error=0` (49 result lines at zero error). - **Software:** `pixel_aot_warp` passed on Microsoft Basic Render Driver (in-box WARP, `1414:008c`), driver `10.0.19041.5794`. Debug errors 0, debug warnings 0. - **Masked-draw mutants:** the `reversed` and `unmasked` mutants are checked inside both GPU tests and must return `mismatch` on each adapter. Both held on WARP and on hardware, and the 9 masked cases (3 programs at thresholds 0.5, 10 and -1) passed. - **Python checks:** `tests/pixel_aot_check.py`, `tests/form_coverage_check.py`, `tests/docs_links_check.py` (126 links) and `tests/bidi_controls_check.py` all exit 0. - **LLVM 15 binary round trip:** `tests/pixel_aot_check.py binary` with LLVM 15.0.7 (`llvm-objcopy`, `LLVM-C.dll`) exits 0. - **Skipped:** None of the GPU tests. This comment only covers the Windows 10 box above. The Win11 / RTX 5070 run from the PR body was not repeated. _AI-assisted (Claude Code)._
MarlomMedeiros commented 2026-11-24 06:48:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T19:52:56Z.


Thanks @rasptum — second independent box to confirm 1a252c8, and it adds a third adapter generation (RTX 3060) and another in-box WARP. Especially useful that the reversed/unmasked mutants held on both your backends, since those are the controls proving the draws actually depend on the mask logic.

AI-assisted: yes. All reported checks ran locally on the adapter and driver listed in the PR body.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084749309 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/651#issuecomment-7084749309). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-22T19:52:56Z. --- Thanks @rasptum — second independent box to confirm `1a252c8`, and it adds a third adapter generation (RTX 3060) and another in-box WARP. Especially useful that the `reversed`/`unmasked` mutants held on both your backends, since those are the controls proving the draws actually depend on the mask logic. AI-assisted: yes. All reported checks ran locally on the adapter and driver listed in the PR body.
R0Y00 commented 2026-11-24 06:49:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T13:13:15Z.


I refreshed your branch in ed2476f and kept the current main line's vector uniform tracking, low-half rules and gfx1030 binary features. The masked region accepts a small per-lane move and binary32 ALU set. Branch-position input now rejects duplicate, unaligned and mixed positioned/unpositioned instructions. The new GPU checks have their own CTest entries.

The LLVM 15 binary regression and form coverage checks passed. On Windows build 26200.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656 each passed the nine mixed/full/empty-mask cases with the debug layer enabled. Both the reversed-predicate and mask-free controls mismatched as expected. GitHub CI is running on the updated head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7102226478 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/651#issuecomment-7102226478). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T13:13:15Z. --- I refreshed your branch in ed2476f and kept the current main line's vector uniform tracking, low-half rules and gfx1030 binary features. The masked region accepts a small per-lane move and binary32 ALU set. Branch-position input now rejects duplicate, unaligned and mixed positioned/unpositioned instructions. The new GPU checks have their own CTest entries. The LLVM 15 binary regression and form coverage checks passed. On Windows build 26200.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656 each passed the nine mixed/full/empty-mask cases with the debug layer enabled. Both the reversed-predicate and mask-free controls mismatched as expected. GitHub CI is running on the updated head.
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!645
No description provided.