startup: lower a compressed export whose unused channel pair is 'off' #1693
No reviewers
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!1693
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1693/head"
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?
@triggered02 on GitHub · 2026-11-24 17:14 UTC · original
triggered02:startup/exp-off→main· +133 −1 · 4 files · 1 commits · closed without mergingFixes #1674. This is the corrected slice; the earlier PR #1681 fixed the wrong path and was closed.
Change
A
comprexport packs two channels into each source register; an export that writes only some channels spells the unwritten pairoff. The translator evaluated that token as an operand and refused the whole translation:Both pairs are handled, not just the common one:
exp mrt4 off, off, v83, v83 done compr(a real encoding from the same cache) zeroes channels 0/1 and reads 2/3.Test
Starts from encoded instructions, decodes them, then translates — the shape matters, because the closed PR tested hand-written assembly through
Stage.one, which the decoder never produces, so it verified a branch real bytes cannot reach.031c00f800808080exp mrt0 v0, v0, off, off done compr vm4cccb1f9d1537dd9exp mrt4 off, off, v83, v83 done compr131c00f81b808080exp mrt1 v27, v27, off, off done compr vmRefusals kept: compressed export into an integer MRT (packed-integer data), and an export with an explicit
en:mask — the parser does not read that mask yet, and exporting all four channels would silently disagree with it.Fail-first: reverting the two lines fails the test with
Unsupported: operand 'off'.Census re-run (local, aggregates only)
Over the same 29 refused cache entries with the change applied: 7 x ok — the seven
exp ... off, offshaders now translate, and nooperand 'off'refusal remains.What this does not establish
tbuffer_load_format_xyzwithBUF_FMT_16_16_16_16_FLOAT, 5;v_cvt_f32_i32withmul:2, 5).en:mask form is its own slice.AI-assisted (Claude Code).
off8b949e2b85@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 17:14 UTC · original · edited 2026-11-24 17:17 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
8b949e2ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@ -0,0 +79,4 @@# 3. The mirror case: off in the first pair and real registers in the second (a real encoding from the same# cache). The fix must handle either pair, not just the one the common case uses.asm, emitted = translate_bytes("4cccb1f9d1537dd9")@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 17:17 UTC · original
The comments identify this test vector (and the companion at line 89) as real encodings from the first main-game loading-screen cache, so the regression test uses game-cache data rather than a source-built or synthetic fixture, or a public sample with a known revision and license. Assemble equivalent instructions from checked-in source or use a permitted sample instead.
AGENTS.md reference: AGENTS.md:L26-L27
Useful? React with 👍 / 👎.
@ -954,0 +954,4 @@# those channels are not written, so they contribute zero instead of being evaluated as an# operand; the disassembler spells it that way for an export that writes only some channels.a = '0u' if vals[0] == 'off' else self.u(vals[0])b = '0u' if vals[2] == 'off' else self.u(vals[2])@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 17:17 UTC · original
When one pair is
off, this substitutes zero but the translator still emits a fullfloat4MRT assignment;hlsl_ps()declares all four components andpipeline_for()defaults toD3D12_COLOR_WRITE_ENABLE_ALLwhen no blend state is recovered. Such draws therefore overwrite the disabled render-target channels with zero instead of leaving them untouched; carry the pair's write mask into the translated PSO or keep refusing this form.Useful? React with 👍 / 👎.
@triggered02 on GitHub · 2026-11-24 17:21 UTC · original
Acknowledging both findings. The P2 changes the right outcome for this PR, so I am closing it rather than patching around it.
P2 — zeroing a disabled pair is not safe here. You are right that the translator emits a full
float4and thatpipeline_for()falls back toD3D12_COLOR_WRITE_ENABLE_ALL. I checked the runtime side:src/startup_stubs/state_block_blend.hstates plainly that "CB_TARGET_MASK has not been located, so every target keeps all four channels". So the disconnected channels are not masked at the PSO, and writing zeros into them overwrites whatever the target held — exactly the corruption you describe. Carrying the pair's mask into the translated PSO is the real fix, and that is a runtime plumbing change (export mask into the manifest, consumed where the write mask is set), not a two-line lowering change.Per your "or keep refusing this form": the refusal stays. I am recording the mask plumbing as the slice that unblocks it rather than landing a lowering that changes what a draw does.
P1 — cache-derived bytes. Correct, and it applies to my tests generally: citing them as "real encodings from the cache" is exactly the prohibited input. The replacement for the still-open typed-buffer-load PR (#1699) is a synthetic encoder in the test that builds the instruction bytes field by field from the documented MTBUF layout and then decodes them; I will re-push that before it draws the same finding. For this PR the test goes away with it.
Thanks for reading the call chain rather than the diff — the
en/write-mask interaction is the kind of thing a passing fixture hides, and this fixture passed in both presets.AI-assisted (Claude Code).
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 17:17 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
8b949e2b85ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@tedin7 on GitHub · 2026-11-24 17:19 UTC · original · reviewed
Peer review at head
8b949e2b855d836428a4c1d4deeea896d07236d0(clean-room, title-neutral, no blocking findings).Code & Semantics Review
tools/startup/gfx2hlsl.py: InStage.export(), when'compr' in flags,vals[0]andvals[2]now map'off'to'0u'beforef16tof32(...)unpacking, matching the existing uncompressedoffhandling ('0.0'/'0u').offinvals[2:4]andoffinvals[0:2]) are handled symmetrically,doneandvmflags continue to be processed viare.fullmatch+execguard, ando.<target>still receives a completefloat4initialization.comprexports (uint/int) remain rejected withUnsupported, and partial-pairen:masks (e.g.en:0xb) remain rejected rather than silently exporting all four channels.tests/startup_gfx2hlsl_export_off_check.py: ExercisesG.decode()->Stage.one()on real 8-byte encodings for both pair positions, multiple MRT targets, and both refusal boundaries.CMakeLists.txt&docs/experiments.md: CTest registration and documentation match the implementation.Verification Executed
Linux:
echo "0x03,0x1c,0x00,0xf8,0x00,0x80,0x80,0x80" | llvm-mc-19 -disassemble -triple=amdgcn-amd-amdhsa -mcpu=gfx1030->exp mrt0 v0, v0, off, off done compr vmpython3 -B tests/startup_gfx2hlsl_export_off_check.py->PASS(10/10 checks)for f in tests/startup_gfx2hlsl_*_check.py; do python3 -B "$f"; done-> all 5startup_gfx2hlsl_*check scripts passed (bit_alu,capture,export_off,sdwa,smem_offset).Local Mutation Check (Linux):
tools/startup/gfx2hlsl.py('0u'->'1u'onvals[0] == 'off'), ranpython3 -B tests/startup_gfx2hlsl_export_off_check.py-> failed as expected (first pair zero, second pair from v83: MISMATCH, exit code 1). Restored withgit checkout -- .and verified cleangit status --short.Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at
8b949e2b855d836428a4c1d4deeea896d07236d0:--preset dev):ctest --preset dev -R '^startup_gfx2hlsl_' --parallel 4 --no-tests=error --output-on-failure-> 7/7 passed (6.52s, includingstartup_gfx2hlsl_export_off0.19s)./O2(--preset release):ctest --preset release -R '^startup_gfx2hlsl_' --parallel 4 --no-tests=error --output-on-failure-> 7/7 passed (6.07s, includingstartup_gfx2hlsl_export_off0.20s).AI-assisted; commands listed were executed locally.
Pull request closed