shader: accept partial channel masks on uncompressed pixel_aot exports #423

Merged
abilliontokens merged 6 commits from upstream-pr/429 into main 2026-11-23 08:24:34 +00:00
abilliontokens commented 2026-11-22 01:45:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T01:45:05Z.


Change

Refs #361 — stage 3 (non-compressed 32-bit exports with per-channel off masks), per the issue's proposed split. Depends on #398 (shader/exp-enable-mask, stage 1), which itself depends on #363; this branch stacks on #398's head and must land after both. Until they merge, the diff against main includes their commits; the incremental change is the single commit on top.

  • lower() now accepts off in any operand of the uncompressed export exp mrt0 vA, vB, vC, vD done vm. Each enabled operand must be a distinct sample/alu register; the four enable bits form the channel mask reported by return_write_mask (so masks 0x1..0xE become reachable for this form, in addition to 0xF). Disabled channels return 0.0f behind the same immaterial-values comment as stage 1, since the harness blocks those writes with the PSO's RenderTargetWriteMask[0]. An all-off export (mask 0) is rejected, and a partial mask combined with integer_export is rejected (out of scope); the full-mask integer path is byte-identical to before.
  • Compressed exports stay restricted to the three LLVM-normalized forms {0x3, 0xC, 0xF}: off inside a compressed export and half-pair text such as v16, off, off, off done compr vm remain rejected. LLVM 15 normalizes compressed half-pair enables to whole pairs, so they are unexpressible in disassembly text (stage 2 stays dropped).
  • Case plumbing: write_case(write_mask=...) accepts any nonzero nibble 0x1..0xF, and the renderer accepts any nonzero trailer nibble (0 keeps the all-channel default), clearing to the sentinel (-1, 2, -3, 4) for every partial mask. Cases written without a trailer keep the original 1280-byte format byte-identically.
  • Fixtures: uncompressed_export(body, mask) builds the per-channel-off text; masks 0x1, 0x8, 0x5, 0xA joined the LLVM 15 assembler round-trip list in check_binary. check_exp_mask_uncompressed_draw draws masks 0x1, 0x8, 0x5, 0xA, 0xF with distinct per-channel constant words through v_sub_f32: enabled channels compare bit-exactly against the reference on the R32G32B32A32 target, disabled channels keep the sentinel. Two negative controls must report pixel_mismatch on every backend: the EN=0x5 shader drawn under an all-channel PSO write mask against the sentinel-expecting reference (receives the immaterial zeros), and a corrupted enabled-channel reference. Rejection controls cover off in a compressed export, compressed half-pair text, the all-off uncompressed export, a duplicated enabled register, and partial mask + integer_export.

Verification

Windows 11 x64 build via tools/dev.ps1 (MSVC), cmake --preset dev -B out/build/dev-361s3 -DINTAKE_PYTHON=out/pe-env/Scripts/python.exe, then:

Gate Command Result
Build cmake --build out/build/dev-361s3 371/371 targets, no warnings
Binary round trip out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py binary <llvm-mc.exe> <llvm15/bin/llvm-objcopy.exe> <llvm15/bin/LLVM-C.dll> pass (incl. the four new per-channel-off fixtures reassembling bit-identically)
WARP ctest --test-dir out/build/dev-361s3 --no-tests=error -R "^pixel_aot_" 2/2 passed (pixel_aot_warp, pixel_aot_hardware)
RX 9060 XT $env:XBOX2WINDOWS_ADAPTER="RX 9060 XT"; ctest ... -R "^pixel_aot_hardware$" 1/1 passed
RTX 5060 Ti $env:XBOX2WINDOWS_ADAPTER="RTX 5060 Ti"; ctest ... -R "^pixel_aot_hardware$" 1/1 passed
Form coverage out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py form coverage checks passed
Full suite ctest --test-dir out/build/dev-361s3 --no-tests=error 146/146 passed; 3 capability skips (bvh_wave64_hardware, bvh_wave64_warp, wave_shuffle_warp)
Negative controls (all three backends): all-channel PSO vs sentinel-expecting reference and corrupted enabled-channel reference each exit 1 with pixel_mismatch; rejection controls raise before any program is recorded for coverage. Sentinels: enabled channels bit-exact, disabled channels hold (-1, 2, -3, 4).

Environment

  • Windows 11 10.0.26200.9711, MSVC 14.44.35207 (VS 2022 Build Tools), CMake dev preset.
  • SDK DXC bin/10.0.26100.0/x64/dxc.exe (dxcompiler 1.8.2502.11), -denorm preserve at ps_6_2.
  • Adapters: AMD RX 9060 XT (32.0.32029.2010), NVIDIA RTX 5060 Ti (32.0.16.2124), WARP 10.0.26100.9711. Debug layer unavailable.
  • Assembler round trip: LLVM 15.0.7 gfx1013 via the clang-wrapper tools.

Evidence / follow-up

  • Measured on LLVM 15.0.7: exp mrt0 v12, off, off, off done vm and the mixed forms reassemble bit-identically, so per-channel off text is authoritative for the uncompressed form (round-trip fixtures pin this).
  • Out of scope, still rejected: other targets (mrt1+, mrtz, null), exports without done vm, multiple exports, partial mask + integer export.
  • #338 (null export after a kill) can build on this stage later.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6536987805 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/429). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T01:45:05Z. --- ## Change Refs #361 — **stage 3** (non-compressed 32-bit exports with per-channel `off` masks), per the issue's proposed split. **Depends on #398** (`shader/exp-enable-mask`, stage 1), which itself depends on #363; this branch stacks on #398's head and must land after both. Until they merge, the diff against `main` includes their commits; the incremental change is the single commit on top. - `lower()` now accepts `off` in any operand of the uncompressed export `exp mrt0 vA, vB, vC, vD done vm`. Each enabled operand must be a distinct sample/alu register; the four enable bits form the channel mask reported by `return_write_mask` (so masks 0x1..0xE become reachable for this form, in addition to 0xF). Disabled channels return `0.0f` behind the same immaterial-values comment as stage 1, since the harness blocks those writes with the PSO's `RenderTargetWriteMask[0]`. An all-off export (mask 0) is rejected, and a partial mask combined with `integer_export` is rejected (out of scope); the full-mask integer path is byte-identical to before. - Compressed exports stay restricted to the three LLVM-normalized forms {0x3, 0xC, 0xF}: `off` inside a compressed export and half-pair text such as `v16, off, off, off done compr vm` remain rejected. LLVM 15 normalizes compressed half-pair enables to whole pairs, so they are unexpressible in disassembly text (stage 2 stays dropped). - Case plumbing: `write_case(write_mask=...)` accepts any nonzero nibble 0x1..0xF, and the renderer accepts any nonzero trailer nibble (0 keeps the all-channel default), clearing to the sentinel (-1, 2, -3, 4) for every partial mask. Cases written without a trailer keep the original 1280-byte format byte-identically. - Fixtures: `uncompressed_export(body, mask)` builds the per-channel-off text; masks 0x1, 0x8, 0x5, 0xA joined the LLVM 15 assembler round-trip list in `check_binary`. `check_exp_mask_uncompressed_draw` draws masks 0x1, 0x8, 0x5, 0xA, 0xF with distinct per-channel constant words through `v_sub_f32`: enabled channels compare bit-exactly against the reference on the R32G32B32A32 target, disabled channels keep the sentinel. Two negative controls must report `pixel_mismatch` on every backend: the EN=0x5 shader drawn under an all-channel PSO write mask against the sentinel-expecting reference (receives the immaterial zeros), and a corrupted enabled-channel reference. Rejection controls cover `off` in a compressed export, compressed half-pair text, the all-off uncompressed export, a duplicated enabled register, and partial mask + `integer_export`. ## Verification Windows 11 x64 build via `tools/dev.ps1` (MSVC), `cmake --preset dev -B out/build/dev-361s3 -DINTAKE_PYTHON=out/pe-env/Scripts/python.exe`, then: | Gate | Command | Result | |---|---|---| | Build | `cmake --build out/build/dev-361s3` | 371/371 targets, no warnings | | Binary round trip | `out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py binary <llvm-mc.exe> <llvm15/bin/llvm-objcopy.exe> <llvm15/bin/LLVM-C.dll>` | pass (incl. the four new per-channel-off fixtures reassembling bit-identically) | | WARP | `ctest --test-dir out/build/dev-361s3 --no-tests=error -R "^pixel_aot_"` | 2/2 passed (`pixel_aot_warp`, `pixel_aot_hardware`) | | RX 9060 XT | `$env:XBOX2WINDOWS_ADAPTER="RX 9060 XT"; ctest ... -R "^pixel_aot_hardware$"` | 1/1 passed | | RTX 5060 Ti | `$env:XBOX2WINDOWS_ADAPTER="RTX 5060 Ti"; ctest ... -R "^pixel_aot_hardware$"` | 1/1 passed | | Form coverage | `out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py` | `form coverage checks passed` | | Full suite | `ctest --test-dir out/build/dev-361s3 --no-tests=error` | 146/146 passed; 3 capability skips (`bvh_wave64_hardware`, `bvh_wave64_warp`, `wave_shuffle_warp`) | Negative controls (all three backends): all-channel PSO vs sentinel-expecting reference and corrupted enabled-channel reference each exit 1 with `pixel_mismatch`; rejection controls raise before any program is recorded for coverage. Sentinels: enabled channels bit-exact, disabled channels hold (-1, 2, -3, 4). ## Environment - Windows 11 10.0.26200.9711, MSVC 14.44.35207 (VS 2022 Build Tools), CMake dev preset. - SDK DXC `bin/10.0.26100.0/x64/dxc.exe` (dxcompiler 1.8.2502.11), `-denorm preserve` at `ps_6_2`. - Adapters: AMD RX 9060 XT (32.0.32029.2010), NVIDIA RTX 5060 Ti (32.0.16.2124), WARP 10.0.26100.9711. Debug layer unavailable. - Assembler round trip: LLVM 15.0.7 gfx1013 via the clang-wrapper tools. ## Evidence / follow-up - Measured on LLVM 15.0.7: `exp mrt0 v12, off, off, off done vm` and the mixed forms reassemble bit-identically, so per-channel `off` text is authoritative for the uncompressed form (round-trip fixtures pin this). - Out of scope, still rejected: other targets (`mrt1`+, `mrtz`, `null`), exports without `done vm`, multiple exports, partial mask + integer export. - #338 (null export after a kill) can build on this stage later.
upstream-sync closed this pull request 2026-11-24 06:43:00 +00:00
R0Y00 commented 2026-11-24 06:49:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T07:06:29Z.


I pushed b639001 after #434 merged. Partial uncompressed exports require the explicit floating-point RT0 mask, with the ordinary API and integer export both refusing them. LLVM 15 and the WARP and hardware Release draws passed for both compressed and uncompressed fixtures. The uncompressed references retain bits below binary16 precision and detect both a wrong PSO mask and a wrong enabled-channel value. Waiting for the final CI.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7093991154 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/429#issuecomment-7093991154). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T07:06:29Z. --- I pushed `b639001` after #434 merged. Partial uncompressed exports require the explicit floating-point RT0 mask, with the ordinary API and integer export both refusing them. LLVM 15 and the WARP and hardware Release draws passed for both compressed and uncompressed fixtures. The uncompressed references retain bits below binary16 precision and detect both a wrong PSO mask and a wrong enabled-channel value. Waiting for the final CI.
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!423
No description provided.