shader: pin compressed EXP enable-mask decoding across all 16 raw EN values #434

Manually merged
github merged 4 commits from gh-pr/434/head into gh-pr/434/base 2026-11-26 21:51:42 +00:00
Owner

@⁠abilliontokens on GitHub · 2026-11-22 02:42 UTC · original
abilliontokens:shader/exp-en-decoding → main · +78 −1 · 3 files · 4 commits · merged 2026-11-23 07:02 UTC

Owner-requested decoding fixture for #361 (comment 7072921152). Stacked on #398, which stacks on #363; review the base PRs first.

Change

Generate the reference compressed export from source (exp mrt0 v16, v16, v17, v17 done compr vm assembles to 0f 1c 00 f8 10 11 00 00: EN is the low nibble of byte 0, byte 1 carries compr/done/vm, and the source VGPRs v16/v17 sit in bytes 4/5). Then independently replace only the four EN bits in the instruction word and exercise all 16 raw masks through the normal binary → disassemble → lower path.

The new check_exp_en_decoding runs as part of the CPU binary gate (tests/pixel_aot_check.py binary) and asserts, for every raw value:

  • Encoded mask: reassembling the disassembled text yields exactly the measured EN.
  • Unchanged source registers: an enabled channel prints its packed source VGPR (v16 for channels 0/1, v17 for channels 2/3) and a disabled channel prints off; raw EN=0x5 prints v16, off, v17, off.
  • Every bit outside EN: the re-encoded word matches the reference outside the EN nibble, with one measured exception — the assembler re-encodes the source-VGPR field of a fully disabled pair as zero.
  • LLVM round-trip: {0x0, 0x3, 0xC, 0xF} round-trip as masks; 0x3/0xC/0xF lower from the patched word identically to the normalized fixture and lower(return_write_mask=True) reports that mask. 0x0 round-trips byte-wise but enables no pair and stays refused.
  • Explicit rejection: every non-pair compressed mask is rejected by lowering with a targeted diagnostic (does not enable whole packed pairs) instead of the generic fall-through; the fixture pins that message. Form coverage counts only accepted programs, so non-pair compressed masks remain excluded.

Measured re-encodings, individually

raw EN 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
re-encoded 0x0 0x3 0x0 0x3 0xc 0xf 0xc 0xf 0x0 0x3 0x0 0x3 0xc 0xf 0xc 0xf

The rule is pair-first-operand presence: a packed pair survives reassembly exactly when its first operand (VSRC0/VSRC2) is enabled; the duplicated high-half operand never enables its pair. That is why 0x2 → 0x0 and 0xa → 0x0 (only the duplicated high-half operand is enabled, so the pair is lost) while 0x5 → 0xf (both first operands enabled). A pairwise OR over both operands of each pair would mispredict the first two as 0x3 and 0xf; the fixture asserts the measured values instead.

Evidence

  • Non-pair compressed masks are rejected by lowering and excluded from form coverage; no accepted form or recorded program changes.
  • Draw behavior for non-pair compressed masks remains deferred: enabling it needs either an ISA definition specific to gfx1013 compressed exports or native execution evidence identifying the channels actually written, then distinct RGBA source values, sentinels for unwritten channels and a negative control in a Windows draw.
  • #429's uncompressed path proceeds independently of this evidence.

Verification

LLVM 15.0.7 gfx1013 tools; no C++ changed.

out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py binary <llvm-mc> <objcopy> <LLVM-C.dll>   # pass (binary round trip + controls + decoding fixture)
out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py                                      # pass
ctest --test-dir out/build/dev-361dec --no-tests=error -R '^pixel_aot_warp$' --output-on-failure    # pass

CI covers the hardware draws.

Refs #361

**@⁠abilliontokens** on GitHub · 2026-11-22 02:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/434) `abilliontokens:shader/exp-en-decoding` → `main` · +78 −1 · 3 files · 4 commits · merged 2026-11-23 07:02 UTC Owner-requested decoding fixture for #361 (comment 7072921152). Stacked on #398, which stacks on #363; review the base PRs first. ## Change Generate the reference compressed export from source (`exp mrt0 v16, v16, v17, v17 done compr vm` assembles to `0f 1c 00 f8 10 11 00 00`: EN is the low nibble of byte 0, byte 1 carries compr/done/vm, and the source VGPRs v16/v17 sit in bytes 4/5). Then independently replace only the four EN bits in the instruction word and exercise all 16 raw masks through the normal binary → disassemble → lower path. The new `check_exp_en_decoding` runs as part of the CPU binary gate (`tests/pixel_aot_check.py binary`) and asserts, for every raw value: - **Encoded mask**: reassembling the disassembled text yields exactly the measured EN. - **Unchanged source registers**: an enabled channel prints its packed source VGPR (v16 for channels 0/1, v17 for channels 2/3) and a disabled channel prints `off`; raw EN=0x5 prints `v16, off, v17, off`. - **Every bit outside EN**: the re-encoded word matches the reference outside the EN nibble, with one measured exception — the assembler re-encodes the source-VGPR field of a fully disabled pair as zero. - **LLVM round-trip**: {0x0, 0x3, 0xC, 0xF} round-trip as masks; 0x3/0xC/0xF lower from the patched word identically to the normalized fixture and `lower(return_write_mask=True)` reports that mask. 0x0 round-trips byte-wise but enables no pair and stays refused. - **Explicit rejection**: every non-pair compressed mask is rejected by lowering with a targeted diagnostic (`does not enable whole packed pairs`) instead of the generic fall-through; the fixture pins that message. Form coverage counts only accepted programs, so non-pair compressed masks remain excluded. ### Measured re-encodings, individually | raw EN | 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0x8 | 0x9 | 0xa | 0xb | 0xc | 0xd | 0xe | 0xf | |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| | re-encoded | 0x0 | 0x3 | 0x0 | 0x3 | 0xc | 0xf | 0xc | 0xf | 0x0 | 0x3 | 0x0 | 0x3 | 0xc | 0xf | 0xc | 0xf | The rule is **pair-first-operand presence**: a packed pair survives reassembly exactly when its first operand (VSRC0/VSRC2) is enabled; the duplicated high-half operand never enables its pair. That is why `0x2 → 0x0` and `0xa → 0x0` (only the duplicated high-half operand is enabled, so the pair is lost) while `0x5 → 0xf` (both first operands enabled). A pairwise OR over both operands of each pair would mispredict the first two as `0x3` and `0xf`; the fixture asserts the measured values instead. ## Evidence - Non-pair compressed masks are rejected by lowering and excluded from form coverage; no accepted form or recorded program changes. - Draw behavior for non-pair compressed masks remains deferred: enabling it needs either an ISA definition specific to gfx1013 compressed exports or native execution evidence identifying the channels actually written, then distinct RGBA source values, sentinels for unwritten channels and a negative control in a Windows draw. - #429's uncompressed path proceeds independently of this evidence. ## Verification LLVM 15.0.7 gfx1013 tools; no C++ changed. ``` out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py binary <llvm-mc> <objcopy> <LLVM-C.dll> # pass (binary round trip + controls + decoding fixture) out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py # pass ctest --test-dir out/build/dev-361dec --no-tests=error -R '^pixel_aot_warp$' --output-on-failure # pass ``` CI covers the hardware draws. Refs #361
Owner-requested decoding fixture for #361, stacked on #398 (which stacks on
#363). Assemble the reference compressed export from source, replace only the
four EN bits of the instruction word for each of the 16 raw values, and decode
every patched word through the normal binary -> disassembly -> lowering path.

The fixture asserts the printed source registers (v16/v17 exactly where a
channel is enabled, off elsewhere), every bit outside EN on re-encoding (the
assembler re-encodes a fully disabled pair's source-VGPR field as zero), and
the measured re-encodings individually: 0x2 -> 0x0, 0xa -> 0x0 and 0x5 -> 0xf,
where a pairwise OR over each pair's operands would mispredict the first two
as 0x3 and 0xf. The rule is pair-first-operand presence: a packed pair
survives reassembly exactly when its first operand (VSRC0/VSRC2) is enabled.

The normalized masks 0x3/0xC/0xF keep the LLVM round-trip and lower through
return_write_mask=True; EN=0x0 round-trips byte-wise but is refused, and every
non-pair compressed mask is now explicitly rejected with a targeted diagnostic
instead of the generic fall-through. Form coverage counts only accepted
programs, so non-pair compressed masks stay excluded. Draw behavior for
non-pair masks awaits a gfx1013-specific compressed-export ISA definition or
native channel-write evidence; #429's uncompressed path is independent.

Refs #361
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:51:41 +00:00
github manually merged commit fd0d8cc69a into gh-pr/434/base 2026-11-26 21:51:42 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 06:44 UTC · original

I pushed fd0d8cc after #398 landed, preserving the author’s full 16-value fixture. The local gfx1013 binary suite passed with LLVM 15.0.7. It checks the raw nibble, the disassembly/reassembly mapping and rejection during lowering of unsupported masks. The raw experiment does not establish native channel-write behavior for those masks.

**@⁠R0Y00** on GitHub · 2026-11-23 06:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/434#issuecomment-7093635036) I pushed `fd0d8cc` after #398 landed, preserving the author’s full 16-value fixture. The local gfx1013 binary suite passed with LLVM 15.0.7. It checks the raw nibble, the disassembly/reassembly mapping and rejection during lowering of unsupported masks. The raw experiment does not establish native channel-write behavior for those masks.
This discussion has been locked. Commenting is limited to contributors.
No description provided.