Skip to content

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

Merged
R0Y00 merged 3 commits into
R0Y00:mainfrom
MarlomMedeiros:shader/pixel-aot-exec-regions
Nov 23, 2026
Merged

R0Y00 merged 3 commits into
R0Y00:mainfrom
MarlomMedeiros:shader/pixel-aot-exec-regions

Conversation

@MarlomMedeiros

@MarlomMedeiros MarlomMedeiros commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 17:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Reject malformed (offset, text) elements with a clean ValueError
instead of leaking TypeError, guard the offset index against empty
tuples, and add controls for aligned SGPR-pair mask sources, double
writes inside a region, the precise merge line, mid-region skips with
corrected offsets, conditional self-reads and bad pair shapes.

Copy link
Copy Markdown
Contributor

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.

@MarlomMedeiros

Copy link
Copy Markdown
Contributor Author

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

rasptum commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

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).

@MarlomMedeiros

Copy link
Copy Markdown
Contributor Author

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

R0Y00 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

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.

@R0Y00
R0Y00 merged commit 5d80e54 into R0Y00:main Nov 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants