pixel_aot: export only the enabled channels (EXP enable mask as pipeline state) #355

Open
opened 2026-11-21 23:21:08 +00:00 by MoonYueya · 16 comments
MoonYueya commented 2026-11-21 23:21:08 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MoonYueya on 2026-11-21T23:21:08Z.


Question

tools/pixel_aot.py lowers a colour export in exactly one form:

exp mrt0 vA, vA, vB, vB done compr vm

In that form all four channels are enabled, two packed f16 pairs are exported, and the target is mrt0. lower() rejects every other export as Unsupported instruction. Rejecting is the safe outcome, since nothing is mistranslated. But it means a program that writes only some channels cannot be translated at all.

How should the translator represent an export whose enable mask (EN) is not 0xF? What is the smallest first step you would accept? I would like to see this split into the stages below.

Evidence so far

All of the following comes from public references. Nothing here was measured in this repository.

  • Enable bits in compressed mode. The AMD RDNA 2 ISA (machine-readable XML, field ENC_EXP.EN) says: "Compressed export: enables for half-dword export; EN[0] for low 16 bits of VSRC0, EN[1] for high 16 bits of VSRC0, EN[2] for low 16 bits of VSRC1, EN[3] for high 16 bits of VSRC1. Non-float16: enables for VSRCs, EN[N] for VSRC[N]."
  • compr packs the sources; it does not convert them. LLVM's int_amdgcn_exp_compr takes two v2f16/v2i16 sources. The lowering bitcasts them and has no fptrunc. This matches the existing fixture, where v_cvt_pkrtz_f16_f32 does the packing and exp ... compr only moves the bits.
  • Disabled channels are not written. A channel whose enable bit is clear keeps the value already in the render target, subject to blending. On desktop D3D12, the closest equivalent is RenderTargetWriteMask in the PSO. HLSL cannot leave one component of an SV_Target return unwritten. So, like the denormal mode in #312, the enable mask is really pipeline state carried alongside the shader, not something the HLSL can express on its own.
  • To confirm: how LLVM 15.0.7 prints a disabled source (I expect off, for example exp mrt0 v0, v0, off, off done compr vm), and whether the assembler accepts that same text back.

Options

Option What it does Cost
A. Return the write mask with the HLSL lower() reports a per-target channel mask, and the harness puts it into RenderTargetWriteMask small API change; the PSO in the test harness has to consume it
B. Keep rejecting partial masks unchanged programs that write only some channels stay untranslatable
C. Write zero to disabled channels — wrong: it overwrites contents the hardware would keep

I propose A, built in the stages below.

Proposed stages (one PR each)

Stage 0: research, no translator change. Record how LLVM 15.0.7 disassembles each compressed enable pattern (0x3, 0xC, 0x1, 0x2, 0x0) and each non-compressed one, and confirm that the text round-trips. Add the forms to the rejection tests, so the current behaviour is pinned.

Stage 1: compressed exports with EN in {0x3, 0xC, 0xF}, mrt0 only. These enable whole pairs, which keeps the first step simple. lower() returns the channel mask, and the harness sets RenderTargetWriteMask. Everything else is still rejected.

Stage 2: compressed half-pair masks (0x1, 0x2, 0x4, 0x8 and their combinations).

Stage 3: non-compressed 32-bit exports (exp mrt0 v0, v1, v2, v3 done vm and partial masks of it), drawn to an R32G32B32A32 target so the bits are kept.

These stay out of scope and keep being rejected:

  • other targets (mrt1+, mrtz, null);
  • exports without done or vm;
  • multiple exports.

Completion condition

Each stage is complete when:

  1. Fixture and round trip. Source-built fixtures in tests/pixel_aot_check.py pass the LLVM 15.0.7 assembler round trip.
  2. Sentinel draws. Before the draw, the render target is cleared to a sentinel colour whose bits differ from every expected output. After the draw, every pixel is compared bit for bit with a CPU reference on WARP and on at least one hardware adapter. Enabled channels must equal the reference. Disabled channels must still hold the sentinel.
  3. Negative controls. Each of these must produce pixel_mismatch:
    • enabling all channels in the PSO while the shader's mask is partial;
    • reading the mask as non-compressed when it is compressed.
  4. Rejections tested. The forms that remain unsupported are tested as rejections.
  5. Coverage and docs updated. scan_unsupported_shaders.py, docs/coverage/*.tsv and the dashboard, and docs/experiments.md are updated.

Relation to other work

  • #312: same principle. State the hardware takes from the pipeline is made an explicit parameter of the case, not inferred from the shader bytes.
  • #338: a kill ends in a null export. That stays out of scope here and can build on stage 3 later.

Note: this issue was drafted with AI assistance. The analysis is based on public references (the RDNA 2 ISA XML and the LLVM AMDGPU sources and documentation) and on this repository's own source. No title data is involved.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535718596 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361). Originally posted by [MoonYueya](https://github.com/MoonYueya) on 2026-11-21T23:21:08Z. --- ## Question `tools/pixel_aot.py` lowers a colour export in exactly one form: ``` exp mrt0 vA, vA, vB, vB done compr vm ``` In that form all four channels are enabled, two packed f16 pairs are exported, and the target is `mrt0`. `lower()` rejects every other export as `Unsupported instruction`. Rejecting is the safe outcome, since nothing is mistranslated. But it means a program that writes only some channels cannot be translated at all. How should the translator represent an export whose enable mask (`EN`) is not `0xF`? What is the smallest first step you would accept? I would like to see this split into the stages below. ## Evidence so far All of the following comes from public references. Nothing here was measured in this repository. - **Enable bits in compressed mode.** The AMD RDNA 2 ISA (machine-readable XML, field `ENC_EXP.EN`) says: *"Compressed export: enables for half-dword export; EN[0] for low 16 bits of VSRC0, EN[1] for high 16 bits of VSRC0, EN[2] for low 16 bits of VSRC1, EN[3] for high 16 bits of VSRC1. Non-float16: enables for VSRCs, EN[N] for VSRC[N]."* - **`compr` packs the sources; it does not convert them.** LLVM's `int_amdgcn_exp_compr` takes two `v2f16`/`v2i16` sources. The lowering bitcasts them and has no `fptrunc`. This matches the existing fixture, where `v_cvt_pkrtz_f16_f32` does the packing and `exp ... compr` only moves the bits. - **Disabled channels are not written.** A channel whose enable bit is clear keeps the value already in the render target, subject to blending. On desktop D3D12, the closest equivalent is `RenderTargetWriteMask` in the PSO. HLSL cannot leave one component of an `SV_Target` return unwritten. So, like the denormal mode in #312, the enable mask is really **pipeline state carried alongside the shader**, not something the HLSL can express on its own. - To confirm: how LLVM 15.0.7 prints a disabled source (I expect `off`, for example `exp mrt0 v0, v0, off, off done compr vm`), and whether the assembler accepts that same text back. ## Options | Option | What it does | Cost | |---|---|---| | A. Return the write mask with the HLSL | `lower()` reports a per-target channel mask, and the harness puts it into `RenderTargetWriteMask` | small API change; the PSO in the test harness has to consume it | | B. Keep rejecting partial masks | unchanged | programs that write only some channels stay untranslatable | | C. Write zero to disabled channels | — | **wrong**: it overwrites contents the hardware would keep | I propose A, built in the stages below. ## Proposed stages (one PR each) **Stage 0: research, no translator change.** Record how LLVM 15.0.7 disassembles each compressed enable pattern (`0x3`, `0xC`, `0x1`, `0x2`, `0x0`) and each non-compressed one, and confirm that the text round-trips. Add the forms to the rejection tests, so the current behaviour is pinned. **Stage 1: compressed exports with `EN` in {`0x3`, `0xC`, `0xF`}, `mrt0` only.** These enable whole pairs, which keeps the first step simple. `lower()` returns the channel mask, and the harness sets `RenderTargetWriteMask`. Everything else is still rejected. **Stage 2: compressed half-pair masks** (`0x1`, `0x2`, `0x4`, `0x8` and their combinations). **Stage 3: non-compressed 32-bit exports** (`exp mrt0 v0, v1, v2, v3 done vm` and partial masks of it), drawn to an R32G32B32A32 target so the bits are kept. These stay out of scope and keep being rejected: - other targets (`mrt1`+, `mrtz`, `null`); - exports without `done` or `vm`; - multiple exports. ## Completion condition Each stage is complete when: 1. **Fixture and round trip.** Source-built fixtures in `tests/pixel_aot_check.py` pass the LLVM 15.0.7 assembler round trip. 2. **Sentinel draws.** Before the draw, the render target is cleared to a sentinel colour whose bits differ from every expected output. After the draw, every pixel is compared bit for bit with a CPU reference on WARP and on at least one hardware adapter. **Enabled channels must equal the reference. Disabled channels must still hold the sentinel.** 3. **Negative controls.** Each of these must produce `pixel_mismatch`: - enabling all channels in the PSO while the shader's mask is partial; - reading the mask as non-compressed when it is compressed. 4. **Rejections tested.** The forms that remain unsupported are tested as rejections. 5. **Coverage and docs updated.** `scan_unsupported_shaders.py`, `docs/coverage/*.tsv` and the dashboard, and `docs/experiments.md` are updated. ## Relation to other work - #312: same principle. State the hardware takes from the pipeline is made an explicit parameter of the case, not inferred from the shader bytes. - #338: a kill ends in a null export. That stays out of scope here and can build on stage 3 later. > Note: this issue was drafted with AI assistance. The analysis is based on public references (the RDNA 2 ISA XML and the LLVM AMDGPU sources and documentation) and on this repository's own source. No title data is involved.
abilliontokens commented 2026-11-24 06:48:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-21T23:58:12Z.


Taking stage 1 (compressed mrt0 exports with EN in {0x3, 0xC, 0xF}) as the first PR: lower() reports the per-target channel mask, the harness sets RenderTargetWriteMask, the target is cleared to a sentinel before the draw, enabled channels compare bit-for-bit against the CPU reference and disabled channels must still hold the sentinel. Negative controls: all-channels-enabled PSO against a partial shader mask, and reading a compressed mask as non-compressed. The LLVM 15 printing survey for these EN patterns (stage 0's question) is folded into the fixture round trips.

Dependency: this stacks on #363 (shader/pixel-fp-mode), which reworks the export branch and the case-file format; #363 must land first, and the PR will name it. Stages 2–3 (half-pair masks, non-compressed partial exports) stay with the proposer.

Environment: Windows 11 Pro 26200.9711, RTX 5060 Ti + RX 9060 XT, WARP 10.0.26100.9711, MSVC 14.44.35207, SDK DXC; LLVM 15.0.7 being provisioned for the round trips. Will link the PR here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071222749 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7071222749). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-21T23:58:12Z. --- Taking **stage 1** (compressed `mrt0` exports with EN in {0x3, 0xC, 0xF}) as the first PR: `lower()` reports the per-target channel mask, the harness sets `RenderTargetWriteMask`, the target is cleared to a sentinel before the draw, enabled channels compare bit-for-bit against the CPU reference and disabled channels must still hold the sentinel. Negative controls: all-channels-enabled PSO against a partial shader mask, and reading a compressed mask as non-compressed. The LLVM 15 printing survey for these EN patterns (stage 0's question) is folded into the fixture round trips. Dependency: this stacks on **#363** (`shader/pixel-fp-mode`), which reworks the export branch and the case-file format; #363 must land first, and the PR will name it. Stages 2–3 (half-pair masks, non-compressed partial exports) stay with the proposer. Environment: Windows 11 Pro 26200.9711, RTX 5060 Ti + RX 9060 XT, WARP 10.0.26100.9711, MSVC 14.44.35207, SDK DXC; LLVM 15.0.7 being provisioned for the round trips. Will link the PR here. _AI-assisted._
abilliontokens commented 2026-11-24 06:48:14 +00:00 (Migrated from github.com)
Author
Contributor

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


Stage-0 printing survey, measured with LLVM 15.0.7 (gfx1013, amdgcn--amdpal), answering the "to confirm" question:

Assembled input Disassembly output EN
exp mrt0 v16, v16, v17, v17 done compr vm identical 0xF
exp mrt0 v16, v16, off, off done compr vm identical 0x3
exp mrt0 off, off, v17, v17 done compr vm identical 0xC
exp mrt0 v16, off, off, off done compr vm v16, v16, off, off 0x1 → 0x3
exp mrt0 off, v16, off, off done compr vm all off 0x2 → 0x0
exp mrt0 off, off, v17, off done compr vm off, off, v17, v17 0x4 → 0xC
exp mrt0 v12, off, off, off done vm (non-compr) identical, per-channel off stage 3

LLVM 15 prints disabled sources as off and the text round-trips. In compressed mode the assembler normalizes half-pair enables to whole pairs, so {0x0, 0x3, 0xC, 0xF} are the only distinguishable compr masks in LLVM 15 text. Stage 2's half-pair masks are not expressible through this syntax and would need a raw-encoding investigation; stage 1's {0x3, 0xC, 0xF} set is exactly the expressible granularity. The stage-1 PR will record this in docs/experiments.md.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071298151 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7071298151). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:04:45Z. --- Stage-0 printing survey, measured with LLVM 15.0.7 (gfx1013, amdgcn--amdpal), answering the "to confirm" question: | Assembled input | Disassembly output | EN | |---|---|---| | `exp mrt0 v16, v16, v17, v17 done compr vm` | identical | 0xF | | `exp mrt0 v16, v16, off, off done compr vm` | identical | 0x3 | | `exp mrt0 off, off, v17, v17 done compr vm` | identical | 0xC | | `exp mrt0 v16, off, off, off done compr vm` | `v16, v16, off, off` | 0x1 → **0x3** | | `exp mrt0 off, v16, off, off done compr vm` | all off | 0x2 → **0x0** | | `exp mrt0 off, off, v17, off done compr vm` | `off, off, v17, v17` | 0x4 → **0xC** | | `exp mrt0 v12, off, off, off done vm` (non-compr) | identical, per-channel off | stage 3 | LLVM 15 prints disabled sources as `off` and the text round-trips. In compressed mode the assembler **normalizes half-pair enables to whole pairs**, so {0x0, 0x3, 0xC, 0xF} are the only distinguishable compr masks in LLVM 15 text. Stage 2's half-pair masks are not expressible through this syntax and would need a raw-encoding investigation; stage 1's {0x3, 0xC, 0xF} set is exactly the expressible granularity. The stage-1 PR will record this in `docs/experiments.md`.
abilliontokens commented 2026-11-24 06:48:14 +00:00 (Migrated from github.com)
Author
Contributor

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


Stage-1 PR up (stacked on #363, which must land first). Verified: LLVM 15.0.7 round trip for the three compr EN programs; sentinel draws bit-exact on WARP 10.0.26100.9711, RX 9060 XT and RTX 5060 Ti — enabled channels match the reference, disabled channels hold the sentinel; both negative controls fail on every backend; form coverage passed. The stage-0 normalization finding is recorded in docs/experiments.md. Stages 2–3 remain open for the proposer.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071483079 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7071483079). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:20:27Z. --- Stage-1 PR up (stacked on #363, which must land first). Verified: LLVM 15.0.7 round trip for the three compr EN programs; sentinel draws bit-exact on WARP 10.0.26100.9711, RX 9060 XT and RTX 5060 Ti — enabled channels match the reference, disabled channels hold the sentinel; both negative controls fail on every backend; form coverage passed. The stage-0 normalization finding is recorded in docs/experiments.md. Stages 2–3 remain open for the proposer.
abilliontokens commented 2026-11-24 06:48:16 +00:00 (Migrated from github.com)
Author
Contributor

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


Taking stage 3 (non-compressed partial channel masks), stacked on #398 → #363. Per-channel off round-trips in LLVM 15.0.7 (measured); the trailer write-mask nibble widens to 0x1..0xF for the uncompressed form, compressed stays {0x3,0xC,0xF}. Sentinel draws + negative controls + LLVM round trip. @MoonYueya flag if you'd rather take this yourself. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072313383 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7072313383). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T01:36:32Z. --- Taking **stage 3** (non-compressed partial channel masks), stacked on #398 → #363. Per-channel `off` round-trips in LLVM 15.0.7 (measured); the trailer write-mask nibble widens to 0x1..0xF for the uncompressed form, compressed stays {0x3,0xC,0xF}. Sentinel draws + negative controls + LLVM round trip. @MoonYueya flag if you'd rather take this yourself. _AI-assisted._
abilliontokens commented 2026-11-24 06:48:17 +00:00 (Migrated from github.com)
Author
Contributor

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


Stage 3 opened as #429 (stacked on #398 → #363). Non-compressed exp mrt0 v0, v1, v2, v3 done vm now takes per-channel off; masks 0x1..0xF travel in the trailer nibble, compressed stays {0x3,0xC,0xF}. Sentinel draws + negative controls pass on WARP, RX 9060 XT and RTX 5060 Ti; per-channel-off programs joined the LLVM 15 round-trip fixtures. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072415055 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7072415055). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T01:45:13Z. --- Stage 3 opened as #429 (stacked on #398 → #363). Non-compressed `exp mrt0 v0, v1, v2, v3 done vm` now takes per-channel `off`; masks 0x1..0xF travel in the trailer nibble, compressed stays {0x3,0xC,0xF}. Sentinel draws + negative controls pass on WARP, RX 9060 XT and RTX 5060 Ti; per-channel-off programs joined the LLVM 15 round-trip fixtures. _AI-assisted._
abilliontokens commented 2026-11-24 06:48:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T02:06:02Z.


Completed the disassembler half of the stage-2 measurement (LLVM 15.0.7, gfx1013, triple amdgcn--amdpal). Base: exp mrt0 v16, v16, v17, v17 done compr vm → 0f 1c 00 f8 10 11 00 00; EN patched in byte 0 low nibble, then disassembled and the printed text reassembled.

EN_raw disasm operands (pos2..5) EN_reasm normalized?
0x0 off, off, off, off 0x0 no
0x1 v16, off, off, off 0x3 yes
0x2 off, v16, off, off 0x0 yes
0x3 v16, v16, off, off 0x3 no
0x4 off, off, v17, off 0xc yes
0x5 v16, off, v17, off 0xf yes
0x6 off, v16, v17, off 0xc yes
0x7 v16, v16, v17, off 0xf yes
0x8 off, off, off, v17 0x0 yes
0x9 v16, off, off, v17 0x3 yes
0xa off, v16, off, v17 0x0 yes
0xb v16, v16, off, v17 0x3 yes
0xc off, off, v17, v17 0xc no
0xd v16, off, v17, v17 0xf yes
0xe off, v16, v17, v17 0xc yes
0xf v16, v16, v17, v17 0xf no

Measured: the disassembler does print non-pair EN masks distinctly (e.g. EN=0x5 → v16, off, v17, off; EN=0xe → off, v16, v17, v17). Reassembling that printed text, however, always normalizes to a whole-pair mask: reassembled EN = raw EN OR-paired per element (each half pair promoted to both, bits {0,1} and {2,3} collapse to 0x3/0xc respectively, 0x5/0xa→0xf, etc.). Only 0x0, 0x3, 0xc, 0xf round-trip.

Conclusion (inferred from the measured table): a real disassembly→lower path can observe non-pair compressed EN masks, but the assembler cannot round-trip them — any re-encode collapses to whole pairs, matching the earlier stage-0 normalization finding. So stage-2 (non-pair compressed enable masks) remains unrepresentable in the source-written fixture / check_binary path: text fixtures can never express them, and raw-binary EN values would not survive an asm re-encode. Stage 2 stays blocked unless the check path compares raw encodings directly without an assembler round-trip.

AI-assisted; measured locally with LLVM 15.0.7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072670691 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7072670691). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T02:06:02Z. --- Completed the disassembler half of the stage-2 measurement (LLVM 15.0.7, gfx1013, triple amdgcn--amdpal). Base: `exp mrt0 v16, v16, v17, v17 done compr vm` → `0f 1c 00 f8 10 11 00 00`; EN patched in byte 0 low nibble, then disassembled and the printed text reassembled. | EN_raw | disasm operands (pos2..5) | EN_reasm | normalized? | |---|---|---|---| | 0x0 | off, off, off, off | 0x0 | no | | 0x1 | v16, off, off, off | 0x3 | yes | | 0x2 | off, v16, off, off | 0x0 | yes | | 0x3 | v16, v16, off, off | 0x3 | no | | 0x4 | off, off, v17, off | 0xc | yes | | 0x5 | v16, off, v17, off | 0xf | yes | | 0x6 | off, v16, v17, off | 0xc | yes | | 0x7 | v16, v16, v17, off | 0xf | yes | | 0x8 | off, off, off, v17 | 0x0 | yes | | 0x9 | v16, off, off, v17 | 0x3 | yes | | 0xa | off, v16, off, v17 | 0x0 | yes | | 0xb | v16, v16, off, v17 | 0x3 | yes | | 0xc | off, off, v17, v17 | 0xc | no | | 0xd | v16, off, v17, v17 | 0xf | yes | | 0xe | off, v16, v17, v17 | 0xc | yes | | 0xf | v16, v16, v17, v17 | 0xf | no | **Measured:** the disassembler *does* print non-pair EN masks distinctly (e.g. EN=0x5 → `v16, off, v17, off`; EN=0xe → `off, v16, v17, v17`). Reassembling that printed text, however, always normalizes to a whole-pair mask: reassembled EN = raw EN OR-paired per element (each half pair promoted to both, bits {0,1} and {2,3} collapse to 0x3/0xc respectively, 0x5/0xa→0xf, etc.). Only 0x0, 0x3, 0xc, 0xf round-trip. **Conclusion (inferred from the measured table):** a real disassembly→lower path *can* observe non-pair compressed EN masks, but the assembler cannot round-trip them — any re-encode collapses to whole pairs, matching the earlier stage-0 normalization finding. So stage-2 (non-pair compressed enable masks) remains unrepresentable in the source-written fixture / `check_binary` path: text fixtures can never express them, and raw-binary EN values would not survive an asm re-encode. Stage 2 stays blocked unless the check path compares raw encodings directly without an assembler round-trip. _AI-assisted; measured locally with LLVM 15.0.7._
R0Y00 commented 2026-11-24 06:48:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T02:27:43Z.


@abilliontokens, please open a focused decoding-fixture PR. Generate a reference compressed EXP from source, then independently replace only the four EN bits in the instruction word. Exercise all 16 masks through the normal binary → disassemble → lower path. Check the encoded mask, the unchanged source registers and every bit outside EN. Keep the LLVM round-trip for the forms it can represent. Please describe the measured re-encodings individually: 0x2 → 0x0, 0xa → 0x0, and 0x5 → 0xf. A pairwise OR rule would mispredict the first two.

For now, lowering should explicitly reject non-pair compressed masks and coverage should exclude them. To enable their draw behavior, we need either an ISA definition specific to gfx1013 compressed exports or native execution evidence identifying the channels actually written. Then use distinct RGBA source values, sentinels for unwritten channels and a negative control in a Windows draw. #429’s uncompressed path can proceed independently of this evidence.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072921152 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7072921152). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T02:27:43Z. --- @abilliontokens, please open a focused decoding-fixture PR. Generate a reference compressed EXP from source, then independently replace only the four EN bits in the instruction word. Exercise all 16 masks through the normal binary → disassemble → lower path. Check the encoded mask, the unchanged source registers and every bit outside EN. Keep the LLVM round-trip for the forms it can represent. Please describe the measured re-encodings individually: `0x2 → 0x0`, `0xa → 0x0`, and `0x5 → 0xf`. A pairwise OR rule would mispredict the first two. For now, lowering should explicitly reject non-pair compressed masks and coverage should exclude them. To enable their draw behavior, we need either an ISA definition specific to gfx1013 compressed exports or native execution evidence identifying the channels actually written. Then use distinct RGBA source values, sentinels for unwritten channels and a negative control in a Windows draw. #429’s uncompressed path can proceed independently of this evidence.
abilliontokens commented 2026-11-24 06:48:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T02:42:04Z.


Acknowledged, and thank you for the correction. Our earlier prose said the re-encoding rule was "OR-paired" over each packed pair's two operands, which mispredicts 0x2 and 0xa (the raw table itself had 0xa → 0x0 correct). The measured rule is pair-first-operand presence: a packed pair survives reassembly exactly when its first operand (VSRC0/VSRC2) is enabled, and the duplicated high-half operand never enables its pair — hence 0x2 → 0x0, 0xa → 0x0 and 0x5 → 0xf individually, where OR would give 0x3 and 0xf for the first two.

Plan for the focused decoding-fixture PR, stacked on #398:

  • Assemble the reference compressed EXP from source (exp mrt0 v16, v16, v17, v17 done compr vm), then independently replace only the four EN bits in the instruction word for each of the 16 raw values, and run every patched word through the normal binary → disassemble → lower path.
  • Assert the encoded mask after reassembly, the unchanged source registers in the printed text (v16/v17 exactly where enabled, off elsewhere), and every bit outside EN — with one measured exception called out: the assembler re-encodes a fully disabled pair's source-VGPR field as zero.
  • Keep the LLVM round-trip for the forms text can represent ({0x0, 0x3, 0xC, 0xF} round-trip as masks; lowering accepts 0x3/0xC/0xF and reports that mask, 0x0 is refused since no pair is enabled).
  • Describe the measured re-encodings individually, including 0x2 → 0x0, 0xa → 0x0 and 0x5 → 0xf, and assert that a pairwise-OR rule would mispredict the first two.
  • Lowering explicitly rejects non-pair compressed masks with a targeted diagnostic (no silent re-encoding), and form coverage excludes them since only accepted programs count.

Draw behavior for non-pair compressed masks stays deferred until there is 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.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073067072 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7073067072). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T02:42:04Z. --- Acknowledged, and thank you for the correction. Our earlier prose said the re-encoding rule was "OR-paired" over each packed pair's two operands, which mispredicts `0x2` and `0xa` (the raw table itself had `0xa → 0x0` correct). The measured rule is pair-first-operand presence: a packed pair survives reassembly exactly when its first operand (VSRC0/VSRC2) is enabled, and the duplicated high-half operand never enables its pair — hence `0x2 → 0x0`, `0xa → 0x0` and `0x5 → 0xf` individually, where OR would give `0x3` and `0xf` for the first two. Plan for the focused decoding-fixture PR, stacked on #398: - Assemble the reference compressed EXP from source (`exp mrt0 v16, v16, v17, v17 done compr vm`), then independently replace only the four EN bits in the instruction word for each of the 16 raw values, and run every patched word through the normal binary → disassemble → lower path. - Assert the encoded mask after reassembly, the unchanged source registers in the printed text (v16/v17 exactly where enabled, `off` elsewhere), and every bit outside EN — with one measured exception called out: the assembler re-encodes a fully disabled pair's source-VGPR field as zero. - Keep the LLVM round-trip for the forms text can represent ({0x0, 0x3, 0xC, 0xF} round-trip as masks; lowering accepts 0x3/0xC/0xF and reports that mask, 0x0 is refused since no pair is enabled). - Describe the measured re-encodings individually, including `0x2 → 0x0`, `0xa → 0x0` and `0x5 → 0xf`, and assert that a pairwise-OR rule would mispredict the first two. - Lowering explicitly rejects non-pair compressed masks with a targeted diagnostic (no silent re-encoding), and form coverage excludes them since only accepted programs count. Draw behavior for non-pair compressed masks stays deferred until there is 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. _AI-assisted._
abilliontokens commented 2026-11-24 06:48:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T02:42:44Z.


Decoding-fixture PR opened as #434, stacked on #398. It exercises all 16 raw EN values through binary → disassemble → lower, asserts the encoded mask, unchanged source registers and every non-EN bit, describes the individual re-encodings (0x2 → 0x0, 0xa → 0x0, 0x5 → 0xf) and the pair-first-operand rule, rejects non-pair compressed masks explicitly and excludes them from coverage.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073074206 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7073074206). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T02:42:44Z. --- Decoding-fixture PR opened as #434, stacked on #398. It exercises all 16 raw EN values through binary → disassemble → lower, asserts the encoded mask, unchanged source registers and every non-EN bit, describes the individual re-encodings (0x2 → 0x0, 0xa → 0x0, 0x5 → 0xf) and the pair-first-operand rule, rejects non-pair compressed masks explicitly and excludes them from coverage. _AI-assisted._
MoonYueya commented 2026-11-24 06:48:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MoonYueya on 2026-11-22T10:25:13Z.


On the stage 3 question: I'm passing on it, and I have no objection to @abilliontokens taking it. I'm not planning PRs for any stage.

On the evidence you asked for: I can only contribute public-reference material, and that is already in the issue. I have no console hardware, so a gfx1013-specific definition or native execution evidence for the channels actually written is out of reach for me. I agree with rejecting non-pair compressed masks in lowering and excluding them from coverage, and I would record stage 2 as blocked rather than pending, since what it still needs is draw-behaviour evidence, not more encoding work.

Two corrections to the issue text, plus a measurement that locates the re-encoding:

  • Stage 2 premise. I assumed half-pair masks could be expressed as text fixtures. They cannot: reassembly keeps a compressed pair exactly when its first operand is present, as #434 asserts.

  • Disabled channels. I wrote that a channel whose enable bit is clear keeps whatever is already in the render target. That was an inference from the RDNA write-mask semantics, not a measured result, and should be read as unverified for gfx1013.

  • Where bits 1 and 3 are lost. I reproduced your table (all 16 raw EN values) with LLVM 15.0.7, 21.1.0 and 23.1.6, each built from source with the AMDGPU target, for both -mcpu=gfx1013 and gfx1030. Every row matches. The loss is in the assembler, not the disassembler:

    • AMDGPUAsmParser::cvtExp (15.0.7 llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp L6334; 21.1.0 L7441; 23.1.6 L8066) copies source slot 2 into slot 1 when compr is set and clears slots 2 and 3. It then builds EnMask from slots 0 and 1 after that copy, that is, from the original slots 0 and 2. Bits 1 and 3 can never survive on their own.
    • AMDGPUInstPrinter::printExpSrcN prints each slot from EN & (1 << N). The disassembled text therefore keeps all four bits, for example exp mrt0 off, v16, off, off done compr vm.
    • Uncompressed exports round-trip all 16 masks.

    Two consequences:

    • The binary → disassemble → lower path that #434 already uses can carry every compressed mask without going through the assembler, so fixtures built that way are feasible at the encoding level. It does not answer the draw-behaviour question above.
    • Upgrading LLVM would not change the re-encoding. One textual difference: 23.1.6 prints a comma after the target (exp mrt0, …), which the current mrt0,? pattern already accepts.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7077780742 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7077780742). Originally posted by [MoonYueya](https://github.com/MoonYueya) on 2026-11-22T10:25:13Z. --- On the stage 3 question: I'm passing on it, and I have no objection to @abilliontokens taking it. I'm not planning PRs for any stage. On the evidence you asked for: I can only contribute public-reference material, and that is already in the issue. I have no console hardware, so a gfx1013-specific definition or native execution evidence for the channels actually written is out of reach for me. I agree with rejecting non-pair compressed masks in lowering and excluding them from coverage, and I would record stage 2 as blocked rather than pending, since what it still needs is draw-behaviour evidence, not more encoding work. Two corrections to the issue text, plus a measurement that locates the re-encoding: - **Stage 2 premise.** I assumed half-pair masks could be expressed as text fixtures. They cannot: reassembly keeps a compressed pair exactly when its first operand is present, as #434 asserts. - **Disabled channels.** I wrote that a channel whose enable bit is clear keeps whatever is already in the render target. That was an inference from the RDNA write-mask semantics, not a measured result, and should be read as unverified for gfx1013. - **Where bits 1 and 3 are lost.** I reproduced your table (all 16 raw EN values) with LLVM 15.0.7, 21.1.0 and 23.1.6, each built from source with the AMDGPU target, for both `-mcpu=gfx1013` and `gfx1030`. Every row matches. The loss is in the **assembler**, not the disassembler: - `AMDGPUAsmParser::cvtExp` (15.0.7 `llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp` L6334; 21.1.0 L7441; 23.1.6 L8066) copies source slot 2 into slot 1 when `compr` is set and clears slots 2 and 3. It then builds `EnMask` from slots 0 and 1 after that copy, that is, from the original slots 0 and 2. Bits 1 and 3 can never survive on their own. - `AMDGPUInstPrinter::printExpSrcN` prints each slot from `EN & (1 << N)`. The disassembled text therefore keeps all four bits, for example `exp mrt0 off, v16, off, off done compr vm`. - Uncompressed exports round-trip all 16 masks. Two consequences: - The binary → disassemble → lower path that #434 already uses can carry every compressed mask without going through the assembler, so fixtures built that way are feasible at the encoding level. It does not answer the draw-behaviour question above. - Upgrading LLVM would not change the re-encoding. One textual difference: 23.1.6 prints a comma after the target (`exp mrt0, …`), which the current `mrt0,?` pattern already accepts. _AI-assisted._
R0Y00 commented 2026-11-24 06:49:05 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T08:26:14Z.


Stage 3 landed in #429 (c1a6589). The uncompressed float RT0 cases compare full FP32 values, preserve sentinel bits in disabled channels, and catch a wrong PSO mask or wrong enabled-channel value. The ordinary API and integer-export path still reject the partial form. Stage 2 remains open for a gfx1013-specific definition or native draw evidence of which channels the non-pair compressed masks actually write. #434 establishes the encoding and rejection controls.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7095443917 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7095443917). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T08:26:14Z. --- Stage 3 landed in #429 (`c1a6589`). The uncompressed float RT0 cases compare full FP32 values, preserve sentinel bits in disabled channels, and catch a wrong PSO mask or wrong enabled-channel value. The ordinary API and integer-export path still reject the partial form. Stage 2 remains open for a gfx1013-specific definition or native draw evidence of which channels the non-pair compressed masks actually write. #434 establishes the encoding and rejection controls.
triggered02 commented 2026-11-24 06:49:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-23T17:31:26Z.


Claiming the remaining ordinary API/integer-export path for partial EXP enable masks.

Environment: Windows 11 Pro 26200, Ryzen 5 5500, GTX 1660 SUPER (32.0.16.1074), MSVC 19.52, DXC 1.9.2602.17, CMake/Ninja, Python 3.12, dev and release.

Scope: after stage 3 (#429), extend tools/pixel_aot.py so the ordinary API/integer export path accepts a partial exp enable mask. The first pass is a source-built fixture with a defined PSO write mask, full pixel readback and a wrong-mask negative control; the stage-3 float cases and sentinels stay unchanged. I am not claiming Stage 2's gfx1013-specific mask meaning or native draw evidence here. If the ordinary path needs that definition, I will report the blocker before changing behavior.

Overlaps: #361 itself; no open PR references it. Stage 3 landed in #429; #434 is merged. I will link the PR here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7108783513 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7108783513). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-23T17:31:26Z. --- Claiming the remaining ordinary API/integer-export path for partial EXP enable masks. Environment: Windows 11 Pro 26200, Ryzen 5 5500, GTX 1660 SUPER (32.0.16.1074), MSVC 19.52, DXC 1.9.2602.17, CMake/Ninja, Python 3.12, `dev` and `release`. Scope: after stage 3 (#429), extend `tools/pixel_aot.py` so the ordinary API/integer export path accepts a partial `exp` enable mask. The first pass is a source-built fixture with a defined PSO write mask, full pixel readback and a wrong-mask negative control; the stage-3 float cases and sentinels stay unchanged. I am not claiming Stage 2's gfx1013-specific mask meaning or native draw evidence here. If the ordinary path needs that definition, I will report the blocker before changing behavior. Overlaps: #361 itself; no open PR references it. Stage 3 landed in #429; #434 is merged. I will link the PR here. AI-assisted.
R0Y00 commented 2026-11-24 06:49:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:36:39Z.


Please proceed with the source-built ordinary/integer slice using uncompressed RT0 masks, where the active channels are explicit. Keep the existing float fixture unchanged. For the integer case, seed each destination channel differently, use a different source word in each enabled channel, and read back every channel using an integer render target. Keep a wrong PSO mask and a wrong enabled word as separate controls. A compressed non-pair mask has a separate evidence requirement and can stay out of this PR.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7108911152 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7108911152). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T17:36:39Z. --- Please proceed with the source-built ordinary/integer slice using uncompressed RT0 masks, where the active channels are explicit. Keep the existing float fixture unchanged. For the integer case, seed each destination channel differently, use a different source word in each enabled channel, and read back every channel using an integer render target. Keep a wrong PSO mask and a wrong enabled word as separate controls. A compressed non-pair mask has a separate evidence requirement and can stay out of this PR.
triggered02 commented 2026-11-24 06:49:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-23T17:43:47Z.


PR: #931
https://github.com/R0Y00/Xbox2Windows/pull/931

Scope: the remaining ordinary/integer slice of this issue. Partial uncompressed exports now use the explicit RT0-mask opt-in for floating-point and integer targets, and the CLI reports the mask as
t0_write_mask. The integer draw seeds each channel differently, uses a different source word per enabled channel, reads back all four channels through an integer render target, and keeps the wrong-PSO-mask and wrong-enabled-word controls separate. The stage-3 float fixture is unchanged. Non-pair compressed masks remain out of scope.

Validation: dev and
elease, 14/14 selected pixel_aot_* tests including WARP and the GTX 1660 SUPER; docs/bidi/shader census/probe pass. The new CLI round-trip test runs in the LLVM binary job; this machine has no LLVM.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7109091607 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7109091607). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-23T17:43:47Z. --- PR: #931 https://github.com/R0Y00/Xbox2Windows/pull/931 Scope: the remaining ordinary/integer slice of this issue. Partial uncompressed exports now use the explicit RT0-mask opt-in for floating-point and integer targets, and the CLI reports the mask as t0_write_mask. The integer draw seeds each channel differently, uses a different source word per enabled channel, reads back all four channels through an integer render target, and keeps the wrong-PSO-mask and wrong-enabled-word controls separate. The stage-3 float fixture is unchanged. Non-pair compressed masks remain out of scope. Validation: dev and elease, 14/14 selected pixel_aot_* tests including WARP and the GTX 1660 SUPER; docs/bidi/shader census/probe pass. The new CLI round-trip test runs in the LLVM binary job; this machine has no LLVM. AI-assisted.
R0Y00 commented 2026-11-24 06:49:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T18:34:54Z.


#931 merged. The ordinary path now has an explicit RT0 write-mask opt-in for uncompressed exports. The integer readback preserves the seeded values in disabled channels and detects both a wrong PSO mask and a wrong enabled word. The packed float fixtures still pass. The remaining scope here is the gfx1013 compressed non-pair masks. For that slice, the next evidence is a native source-built draw showing which destination components are written with distinct source values and prefilled destination sentinels, or an ISA definition specific enough to distinguish those encodings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7110364104 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7110364104). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T18:34:54Z. --- #931 merged. The ordinary path now has an explicit RT0 write-mask opt-in for uncompressed exports. The integer readback preserves the seeded values in disabled channels and detects both a wrong PSO mask and a wrong enabled word. The packed float fixtures still pass. The remaining scope here is the gfx1013 compressed non-pair masks. For that slice, the next evidence is a native source-built draw showing which destination components are written with distinct source values and prefilled destination sentinels, or an ISA definition specific enough to distinguish those encodings.
triggered02 commented 2026-11-24 06:49:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-23T18:48:58Z.


Merged as �f0c3eb (#931). The ordinary path now requires the explicit --rt0-write-mask opt-in for uncompressed exports, reports the mask as
t0_write_mask, and the integer draw reads all four channels with separate wrong-PSO-mask and wrong-enabled-word controls. Stage 2's non-pair compressed-mask evidence requirement remains open and out of this change.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7110693804 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/361#issuecomment-7110693804). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-23T18:48:58Z. --- Merged as �f0c3eb (#931). The ordinary path now requires the explicit --rt0-write-mask opt-in for uncompressed exports, reports the mask as t0_write_mask, and the integer draw reads all four channels with separate wrong-PSO-mask and wrong-enabled-word controls. Stage 2's non-pair compressed-mask evidence requirement remains open and out of this change. AI-assisted.
Sign in to join this conversation.
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#355
No description provided.