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

Manually merged
github merged 6 commits from gh-pr/398/head into gh-pr/398/base 2026-11-26 21:48:50 +00:00
Owner

@⁠abilliontokens on GitHub · 2026-11-22 00:20 UTC · original
abilliontokens:shader/exp-enable-mask → main · +116 −13 · 5 files · 6 commits · merged 2026-11-23 06:03 UTC

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.

**@⁠abilliontokens** on GitHub · 2026-11-22 00:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/398) `abilliontokens:shader/exp-enable-mask` → `main` · +116 −13 · 5 files · 6 commits · merged 2026-11-23 06:03 UTC ## 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._
Refs #312. Record the preserve assumption the CPU references make, compile every draw fixture with a matching -denorm flag at ps_6_2, and add a non-folding preserve-vs-FTZ control on the least subnormal through a new uncompressed f32 export. Accept NaN by class only on rows expecting NaN via a case-file mask trailer, log raw words, keep predicates and unmasked channels strict, and round-trip integer moves bit-for-bit through a UINT readback target. The curve fixture records mode any: the RTX 5060 Ti driver 32.0.16.2124 refuses PSO creation for that program under preserve.
Refs #312. The curve fixture runs under -denorm any because the RTX 5060 Ti driver refuses preserve for that program; check every expected word is unchanged by flushing so the mode-independence claim is machine-checked.
Refs #361 (stage 1). EN {0x3,0xC,0xF} compr mrt0 exports report a channel mask via lower(return_write_mask=True); the harness applies it as PSO RenderTargetWriteMask with a sentinel-cleared target so disabled channels keep the sentinel. Trailer flags high nibble carries the mask. LLVM 15 normalizes half-pair enables to whole pairs (recorded); EN=0, mixed text, half-pair text, uncompressed off and partial+integer_export stay rejected. Stacked on #363.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:48:48 +00:00
github manually merged commit 2614f22352 into gh-pr/398/base 2026-11-26 21:48:50 +00:00
Author
Owner

@⁠MoonYueya on GitHub · 2026-11-22 00:21 UTC · original

I have sleep🥰

**@⁠MoonYueya** on GitHub · 2026-11-22 00:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7071496104) I have sleep🥰
Author
Owner

@⁠abilliontokens on GitHub · 2026-11-22 00:32 UTC · original

I have sleep🥰

ur going to sleep? good night

**@⁠abilliontokens** on GitHub · 2026-11-22 00:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7071618471) > I have sleep🥰 ur going to sleep? good night
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 05:13 UTC · original

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** on GitHub · 2026-11-23 05:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7092224123) 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 05:48 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-23 05:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/398#issuecomment-7092754870) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.