shader: export only the enabled channels in pixel_aot compressed exports #392

Merged
abilliontokens merged 6 commits from upstream-pr/398 into main 2026-11-23 06:03:33 +00:00
abilliontokens commented 2026-11-22 00:20:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T00:20:25Z.


Change

Refs #361 — stage 1 only (compressed mrt0 exports with EN ∈ {0x3, 0xC, 0xF}), per the issue's proposed split; stages 2–3 stay with the proposer.

Depends on #363 (shader/pixel-fp-mode), which must land first: this branch stacks on its export-branch rework and case-file trailer. Until #363 merges, the diff against main includes #363's commits; the incremental change is the single commit on top.

  • lower() gains keyword-only return_write_mask=False; with True it returns (hlsl, channel_mask). Default callers are unchanged. Two new anchored branches accept the LLVM-normalized partial compr forms exp mrt0 vA, vA, off, off done compr vm (mask 0x3) and exp mrt0 off, off, vB, vB done compr vm (mask 0xC), with the same guards as the 0xF branch. Partial exports still return float4: the enabled pair via export16, disabled channels emit 0.0f with a comment that the PSO write mask prevents those writes.
  • The harness applies the mask as PSO RenderTargetWriteMask[0]. Case-file trailer flags byte: bit 0 = integer RT (#363, unchanged), high nibble = RT0 write mask (0 → default 0xF; only 0x3/0xC/0xF accepted, other nibbles and low bits 1–3 are format errors). No-trailer files behave exactly as before.
  • Sentinel draws: with a partial mask the target is cleared to the documented finite sentinel (-1, 2, -3, 4); enabled channels compare bit-for-bit against the CPU reference, disabled channels must still hold the sentinel. Full-mask clears are unchanged.
  • Rejected (with controls): EN=0 all-off exports, non-normalized mixed text, half-pair text, off in the uncompressed form (stage 3), partial mask + integer_export, and write_mask + integer_rt cases.
  • Measured stage-0 finding (LLVM 15.0.7, gfx1013): the assembler normalizes half-pair enables to whole pairs — v16, off, off, off prints as v16, v16, off, off (0x1→0x3), off, v16, off, off prints all-off (0x2→0x0), off, off, v17, off prints as off, off, v17, v17 (0x4→0xC). {0x0, 0x3, 0xC, 0xF} are the only distinguishable compr masks in LLVM 15 text, so stage 2's half-pair masks need a raw-encoding investigation; recorded in docs/experiments.md and on the issue.
  • The three compr EN programs join check_binary's LLVM 15 round-trip list.

Verification

Environment: Windows 11 Pro build 26200.9711, MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Windows SDK 10.0.26100.0 (its DXC), CMake 4.4.3 / Ninja 1.13.2, Python 3.12.10. Adapters: AMD RX 9060 XT (32.0.32029.2010), NVIDIA RTX 5060 Ti (32.0.16.2124), in-box WARP 10.0.26100.9711. Debug layer unavailable (Graphics Tools not installed); runs report debug_layer=unavailable. LLVM 15.0.7 official win64 binaries (installer omits llvm-mc; assembly via clang 15.0.7's integrated assembler through a local argv wrapper, disassembly via LLVM-C.dll 15.0.7).

cmake --preset dev
cmake --build --preset dev
python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>
ctest --preset dev --no-tests=error -R '^pixel_aot_' --output-on-failure
$env:XBOX2WINDOWS_ADAPTER='RX 9060 XT'
ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
$env:XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'
ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py

Result at this branch (rebased onto main at 4f6c39d via #363; isolated worktree configured with the dev preset, ctest via --test-dir on that build, same filters):

Run Result
pixel_aot_check.py binary (LLVM 15.0.7 round trip, all fixtures incl. the three compr EN programs) passed
pixel_aot_hardware (default adapter, RTX 5060 Ti) Passed, 22.1 s
pixel_aot_warp (WARP 10.0.26100.9711) Passed, 4.3 s
pixel_aot_hardware with XBOX2WINDOWS_ADAPTER='RX 9060 XT' Passed, 16.0 s
pixel_aot_hardware with XBOX2WINDOWS_ADAPTER='RTX 5060 Ti' Passed, 22.4 s
tests/form_coverage_check.py passed

Enabled channels match the reference bit-for-bit and disabled channels hold the sentinel on all three backends; both negative controls report pixel_mismatch on every backend. Capability skips: none in this group.

Negative controls (fail on every backend): the partial-mask shader drawn with an all-channels PSO against the sentinel-expecting reference (the immaterial 0.0f lands in disabled channels → pixel_mismatch), and a corrupted enabled-channel reference.

Evidence and follow-up

  • docs/experiments.md records the write-mask pipeline-state contract, the trailer nibble, the sentinel rule, the LLVM normalization finding, and the remaining rejections.
  • All existing fixtures and no-trailer case files are byte-identical; full-mask behavior is unchanged.
  • Stage 2 (half-pair masks — needs a representation beyond LLVM 15 compr text) and stage 3 (non-compressed partial exports) remain open on #361 for the proposer.
  • No game files, dumps, distribution links or credentials; fixtures are source-built and synthetic.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6536264452 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/398). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:20:25Z. --- ## Change Refs #361 — **stage 1 only** (compressed `mrt0` exports with EN ∈ {0x3, 0xC, 0xF}), per the issue's proposed split; stages 2–3 stay with the proposer. **Depends on #363** (`shader/pixel-fp-mode`), which must land first: this branch stacks on its export-branch rework and case-file trailer. Until #363 merges, the diff against `main` includes #363's commits; the incremental change is the single commit on top. - `lower()` gains keyword-only `return_write_mask=False`; with `True` it returns `(hlsl, channel_mask)`. Default callers are unchanged. Two new anchored branches accept the LLVM-normalized partial compr forms `exp mrt0 vA, vA, off, off done compr vm` (mask 0x3) and `exp mrt0 off, off, vB, vB done compr vm` (mask 0xC), with the same guards as the 0xF branch. Partial exports still return `float4`: the enabled pair via `export16`, disabled channels emit `0.0f` with a comment that the PSO write mask prevents those writes. - The harness applies the mask as PSO `RenderTargetWriteMask[0]`. Case-file trailer flags byte: bit 0 = integer RT (#363, unchanged), **high nibble = RT0 write mask** (0 → default 0xF; only 0x3/0xC/0xF accepted, other nibbles and low bits 1–3 are format errors). No-trailer files behave exactly as before. - Sentinel draws: with a partial mask the target is cleared to the documented finite sentinel `(-1, 2, -3, 4)`; enabled channels compare bit-for-bit against the CPU reference, disabled channels must still hold the sentinel. Full-mask clears are unchanged. - Rejected (with controls): EN=0 all-off exports, non-normalized mixed text, half-pair text, `off` in the uncompressed form (stage 3), partial mask + `integer_export`, and `write_mask` + `integer_rt` cases. - **Measured stage-0 finding** (LLVM 15.0.7, gfx1013): the assembler normalizes half-pair enables to whole pairs — `v16, off, off, off` prints as `v16, v16, off, off` (0x1→0x3), `off, v16, off, off` prints all-off (0x2→0x0), `off, off, v17, off` prints as `off, off, v17, v17` (0x4→0xC). {0x0, 0x3, 0xC, 0xF} are the only distinguishable compr masks in LLVM 15 text, so stage 2's half-pair masks need a raw-encoding investigation; recorded in `docs/experiments.md` and on the issue. - The three compr EN programs join `check_binary`'s LLVM 15 round-trip list. ## Verification Environment: Windows 11 Pro build 26200.9711, MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Windows SDK 10.0.26100.0 (its DXC), CMake 4.4.3 / Ninja 1.13.2, Python 3.12.10. Adapters: AMD RX 9060 XT (32.0.32029.2010), NVIDIA RTX 5060 Ti (32.0.16.2124), in-box WARP 10.0.26100.9711. Debug layer unavailable (Graphics Tools not installed); runs report `debug_layer=unavailable`. LLVM 15.0.7 official win64 binaries (installer omits `llvm-mc`; assembly via clang 15.0.7's integrated assembler through a local argv wrapper, disassembly via `LLVM-C.dll` 15.0.7). ```powershell cmake --preset dev cmake --build --preset dev python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll> ctest --preset dev --no-tests=error -R '^pixel_aot_' --output-on-failure $env:XBOX2WINDOWS_ADAPTER='RX 9060 XT' ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure $env:XBOX2WINDOWS_ADAPTER='RTX 5060 Ti' ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py ``` Result at this branch (rebased onto `main` at `4f6c39d` via #363; isolated worktree configured with the `dev` preset, ctest via `--test-dir` on that build, same filters): | Run | Result | |---|---| | `pixel_aot_check.py binary` (LLVM 15.0.7 round trip, all fixtures incl. the three compr EN programs) | passed | | `pixel_aot_hardware` (default adapter, RTX 5060 Ti) | Passed, 22.1 s | | `pixel_aot_warp` (WARP 10.0.26100.9711) | Passed, 4.3 s | | `pixel_aot_hardware` with `XBOX2WINDOWS_ADAPTER='RX 9060 XT'` | Passed, 16.0 s | | `pixel_aot_hardware` with `XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'` | Passed, 22.4 s | | `tests/form_coverage_check.py` | passed | Enabled channels match the reference bit-for-bit and disabled channels hold the sentinel on all three backends; both negative controls report `pixel_mismatch` on every backend. Capability skips: none in this group. Negative controls (fail on every backend): the partial-mask shader drawn with an all-channels PSO against the sentinel-expecting reference (the immaterial `0.0f` lands in disabled channels → `pixel_mismatch`), and a corrupted enabled-channel reference. ## Evidence and follow-up - `docs/experiments.md` records the write-mask pipeline-state contract, the trailer nibble, the sentinel rule, the LLVM normalization finding, and the remaining rejections. - All existing fixtures and no-trailer case files are byte-identical; full-mask behavior is unchanged. - Stage 2 (half-pair masks — needs a representation beyond LLVM 15 compr text) and stage 3 (non-compressed partial exports) remain open on #361 for the proposer. - No game files, dumps, distribution links or credentials; fixtures are source-built and synthetic. _AI-assisted._
upstream-sync closed this pull request 2026-11-24 06:42:50 +00:00
MoonYueya commented 2026-11-24 06:48:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MoonYueya on 2026-11-22T00:21:36Z.


I have sleep🥰

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071496104 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7071496104). Originally posted by [MoonYueya](https://github.com/MoonYueya) on 2026-11-22T00:21:36Z. --- I have sleep🥰
abilliontokens commented 2026-11-24 06:48:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T00:32:29Z.


I have sleep🥰

ur going to sleep? good night

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071618471 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7071618471). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:32:29Z. --- > I have sleep🥰 ur going to sleep? good night
R0Y00 commented 2026-11-24 06:49:01 +00:00 (Migrated from github.com)

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


One integration guard before the stage-1 patch lands: the new high-pair path emits zeros for the disabled channels but currently also returns only HLSL when return_write_mask is false. That lets the normal caller draw zeros into channels the guest did not write. Require the explicit write-mask return on newly accepted partial forms, and add a default-call rejection control for the high pair. Preserve any existing low-pair caller behavior. Please keep the PSO-mask and sentinel controls, and limit this branch to comments and code for the normalized paired forms. The raw EN cases stay in #434; a normalized disassembly string alone cannot establish support for a non-paired mask.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7092224123 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7092224123). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T05:13:45Z. --- One integration guard before the stage-1 patch lands: the new high-pair path emits zeros for the disabled channels but currently also returns only HLSL when `return_write_mask` is false. That lets the normal caller draw zeros into channels the guest did not write. Require the explicit write-mask return on newly accepted partial forms, and add a default-call rejection control for the high pair. Preserve any existing low-pair caller behavior. Please keep the PSO-mask and sentinel controls, and limit this branch to comments and code for the normalized paired forms. The raw EN cases stay in #434; a normalized disassembly string alone cannot establish support for a non-paired mask.
R0Y00 commented 2026-11-24 06:49:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T05:48:52Z.


I pushed 2614f22 to resolve the conflicts and preserve the existing float2 path. The high-pair export requires the explicit RT0-mask result. The new focused draw passed on WARP and hardware under /O2: RG, BA and RGBA matched their references, both partial masks preserved the clear sentinels, and the full-mask and wrong-value controls failed as expected. Waiting for the fresh CI, including the LLVM 15 round trip.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7092754870 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7092754870). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T05:48:52Z. --- I pushed `2614f22` to resolve the conflicts and preserve the existing float2 path. The high-pair export requires the explicit RT0-mask result. The new focused draw passed on WARP and hardware under `/O2`: RG, BA and RGBA matched their references, both partial masks preserved the clear sentinels, and the full-mask and wrong-value controls failed as expected. Waiting for the fresh CI, including the LLVM 15 round trip.
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!392
No description provided.