pixel_aot: export only the enabled channels (EXP enable mask as pipeline state) #361
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#361
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@MoonYueya on GitHub · 2026-11-21 23:21 UTC · original
Question
tools/pixel_aot.pylowers a colour export in exactly one form:In that form all four channels are enabled, two packed f16 pairs are exported, and the target is
mrt0.lower()rejects every other export asUnsupported 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 not0xF? 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.
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]."comprpacks the sources; it does not convert them. LLVM'sint_amdgcn_exp_comprtakes twov2f16/v2i16sources. The lowering bitcasts them and has nofptrunc. This matches the existing fixture, wherev_cvt_pkrtz_f16_f32does the packing andexp ... compronly moves the bits.RenderTargetWriteMaskin the PSO. HLSL cannot leave one component of anSV_Targetreturn 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.off, for exampleexp mrt0 v0, v0, off, off done compr vm), and whether the assembler accepts that same text back.Options
lower()reports a per-target channel mask, and the harness puts it intoRenderTargetWriteMaskI 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
ENin {0x3,0xC,0xF},mrt0only. These enable whole pairs, which keeps the first step simple.lower()returns the channel mask, and the harness setsRenderTargetWriteMask. Everything else is still rejected.Stage 2: compressed half-pair masks (
0x1,0x2,0x4,0x8and their combinations).Stage 3: non-compressed 32-bit exports (
exp mrt0 v0, v1, v2, v3 done vmand partial masks of it), drawn to an R32G32B32A32 target so the bits are kept.These stay out of scope and keep being rejected:
mrt1+,mrtz,null);doneorvm;Completion condition
Each stage is complete when:
tests/pixel_aot_check.pypass the LLVM 15.0.7 assembler round trip.pixel_mismatch:scan_unsupported_shaders.py,docs/coverage/*.tsvand the dashboard, anddocs/experiments.mdare updated.Relation to other work
@abilliontokens on GitHub · 2026-11-21 23:58 UTC · original
Taking stage 1 (compressed
mrt0exports with EN in {0x3, 0xC, 0xF}) as the first PR:lower()reports the per-target channel mask, the harness setsRenderTargetWriteMask, 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 on GitHub · 2026-11-22 00:04 UTC · original
Stage-0 printing survey, measured with LLVM 15.0.7 (gfx1013, amdgcn--amdpal), answering the "to confirm" question:
exp mrt0 v16, v16, v17, v17 done compr vmexp mrt0 v16, v16, off, off done compr vmexp mrt0 off, off, v17, v17 done compr vmexp mrt0 v16, off, off, off done compr vmv16, v16, off, offexp mrt0 off, v16, off, off done compr vmexp mrt0 off, off, v17, off done compr vmoff, off, v17, v17exp mrt0 v12, off, off, off done vm(non-compr)LLVM 15 prints disabled sources as
offand 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 indocs/experiments.md.@abilliontokens on GitHub · 2026-11-22 00:20 UTC · original
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 on GitHub · 2026-11-22 01:36 UTC · original
Taking stage 3 (non-compressed partial channel masks), stacked on #398 → #363. Per-channel
offround-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 on GitHub · 2026-11-22 01:45 UTC · original
Stage 3 opened as #429 (stacked on #398 → #363). Non-compressed
exp mrt0 v0, v1, v2, v3 done vmnow takes per-channeloff; 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 on GitHub · 2026-11-22 02:06 UTC · original
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.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_binarypath: 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 on GitHub · 2026-11-22 02:27 UTC · original
@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, and0x5 → 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 on GitHub · 2026-11-22 02:42 UTC · original
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
0x2and0xa(the raw table itself had0xa → 0x0correct). 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 — hence0x2 → 0x0,0xa → 0x0and0x5 → 0xfindividually, where OR would give0x3and0xffor the first two.Plan for the focused decoding-fixture PR, stacked on #398:
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.offelsewhere), 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.0x2 → 0x0,0xa → 0x0and0x5 → 0xf, and assert that a pairwise-OR rule would mispredict the first two.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 on GitHub · 2026-11-22 02:42 UTC · original
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 on GitHub · 2026-11-22 10:25 UTC · original
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=gfx1013andgfx1030. Every row matches. The loss is in the assembler, not the disassembler:AMDGPUAsmParser::cvtExp(15.0.7llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cppL6334; 21.1.0 L7441; 23.1.6 L8066) copies source slot 2 into slot 1 whencompris set and clears slots 2 and 3. It then buildsEnMaskfrom 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::printExpSrcNprints each slot fromEN & (1 << N). The disassembled text therefore keeps all four bits, for exampleexp mrt0 off, v16, off, off done compr vm.Two consequences:
exp mrt0, …), which the currentmrt0,?pattern already accepts.AI-assisted.
@R0Y00 on GitHub · 2026-11-23 08:26 UTC · original
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 on GitHub · 2026-11-23 17:31 UTC · original
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,
devandrelease.Scope: after stage 3 (#429), extend
tools/pixel_aot.pyso the ordinary API/integer export path accepts a partialexpenable 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 on GitHub · 2026-11-23 17:36 UTC · original
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 on GitHub · 2026-11-23 17:43 UTC · original
PR: #931
#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 on GitHub · 2026-11-23 18:34 UTC · original
#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 on GitHub · 2026-11-23 18:48 UTC · original
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.