startup: carry a compressed export's channel mask so 'off' channels are not written (7 of 29 loading-screen shader refusals) #1667

Closed
opened 2026-11-24 16:49:51 +00:00 by triggered02 · 1 comment
triggered02 commented 2026-11-24 16:49:51 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T16:49:51Z.


Found while triaging the refusals in the first main-game loading-screen shader cache (#870). 7 of 29 refused shaders.

Correction to the earlier report

This issue was first filed as the SMEM offset operand off, then corrected to the compressed export below. A pull request lowered the export form (#1693) and was closed after review found that lowering it alone changes what a draw writes: see "Why the lowering alone is unsafe" below. The remaining work is the write mask, not the lowering.

The refusal

gfx2hlsl refuses an exp whose unused channel pair is spelled off, which is how a compressed export that writes only the first two channels is printed:

exp mrt0 v0, v0, off, off done compr vm
-> REFUSED: operand 'off'

Cause: Stage.export() handles off in the non-compressed branches ('0u' if v == 'off' else ...) but the compr branch reads both source pairs unconditionally.

Why the lowering alone is unsafe

compr packs two channels per source register, so off in the second pair means channels 2/3 are not written. The translator emits a full float4 MRT assignment, and src/startup_stubs/state_block_blend.h records that CB_TARGET_MASK has not been located, so every target keeps all four channels (D3D12_COLOR_WRITE_ENABLE_ALL). Substituting zero for the off pair therefore overwrites channels the console shader leaves untouched — a silent content change on any target that already held data.

Deliverable

Carry the export's channel mask into the translated PSO:

  • the translator records, per render target, which channels the export writes (from the off sources, and from an explicit en: mask where present);
  • the manifest carries that mask to the runtime;
  • the runtime sets RenderTargetWriteMask from it when the console blend state does not provide CB_TARGET_MASK.

Then the compressed export with off channels can lower, and an explicit en: mask stops being refused for lack of a consumer.

Done when

  • A compressed export with off in either pair lowers, and the translated pipeline's write mask excludes exactly those channels.
  • A test starts from synthetic encoded instructions built from the documented MTBUF/EXP layouts (not cache-derived bytes — a review on #1693 correctly rejected that input), goes through decode(), and checks both the lowered HLSL and the recorded mask.
  • The runtime side sets the write mask from the manifest, with a test that a target outside the mask is not written.
  • Refusals kept: packed-integer compr exports, unnamed formats, and any export whose mask cannot be represented.

Not in this slice: which value a partially written channel should take, and the other refusal groups in the census.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6586909289 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1674). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T16:49:51Z. --- Found while triaging the refusals in the first main-game loading-screen shader cache (#870). **7 of 29** refused shaders. ## Correction to the earlier report This issue was first filed as the SMEM offset operand `off`, then corrected to the compressed export below. A pull request lowered the export form (#1693) and was closed after review found that lowering it alone changes what a draw writes: see "Why the lowering alone is unsafe" below. The remaining work is the write mask, not the lowering. ## The refusal `gfx2hlsl` refuses an `exp` whose unused channel pair is spelled `off`, which is how a compressed export that writes only the first two channels is printed: ``` exp mrt0 v0, v0, off, off done compr vm -> REFUSED: operand 'off' ``` Cause: `Stage.export()` handles `off` in the non-compressed branches (`'0u' if v == 'off' else ...`) but the `compr` branch reads both source pairs unconditionally. ## Why the lowering alone is unsafe `compr` packs two channels per source register, so `off` in the second pair means channels 2/3 are **not written**. The translator emits a full `float4` MRT assignment, and `src/startup_stubs/state_block_blend.h` records that `CB_TARGET_MASK` has not been located, so every target keeps all four channels (`D3D12_COLOR_WRITE_ENABLE_ALL`). Substituting zero for the `off` pair therefore overwrites channels the console shader leaves untouched — a silent content change on any target that already held data. ## Deliverable Carry the export's channel mask into the translated PSO: - the translator records, per render target, which channels the export writes (from the `off` sources, and from an explicit `en:` mask where present); - the manifest carries that mask to the runtime; - the runtime sets `RenderTargetWriteMask` from it when the console blend state does not provide `CB_TARGET_MASK`. Then the compressed export with `off` channels can lower, and an explicit `en:` mask stops being refused for lack of a consumer. ## Done when - A compressed export with `off` in either pair lowers, and the translated pipeline's write mask excludes exactly those channels. - A test starts from **synthetic** encoded instructions built from the documented MTBUF/EXP layouts (not cache-derived bytes — a review on #1693 correctly rejected that input), goes through `decode()`, and checks both the lowered HLSL and the recorded mask. - The runtime side sets the write mask from the manifest, with a test that a target outside the mask is not written. - Refusals kept: packed-integer `compr` exports, unnamed formats, and any export whose mask cannot be represented. Not in this slice: which value a *partially* written channel should take, and the other refusal groups in the census. AI-assisted (Claude Code).
upstream-sync changed title from [GH #1674] startup: gfx2hlsl refuses the SMEM offset form 'off' (7 of 29 loading-screen shader refusals) to [GH #1674] startup: carry a compressed export's channel mask so 'off' channels are not written (7 of 29 loading-screen shader refusals) 2026-11-24 18:02:25 +00:00
mumba17 commented 2026-11-24 20:01:19 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-24T19:38:07Z.


This issue was closed at 17:07 by the commit for the SMEM off fix (#1676). The compressed-export deliverable above is still open: on main at ecc6e6ce, exp mrt0 v0, v0, off, off done compr vm is still refused as operand 'off'.

Local count: on an RTX 3090 with a warm cache from the first-run setup through the post-confirm load, 16 of 110 refused pipelines stop at this export, and nothing earlier refuses them.

Claiming the deliverable as written above:

  • the translator records the channel mask per render target from the off pairs and an explicit en: mask;
  • the manifest carries the mask;
  • the runtime sets RenderTargetWriteMask from it when the console blend state gives no CB_TARGET_MASK.

Tests:

  • start from synthetic encoded EXP instructions through decode();
  • check the lowered HLSL and the recorded mask;
  • check on the runtime side that a channel outside the mask is not written.

Refusals kept: packed-integer compr, unnamed formats, and masks that cannot be represented.

@R0Y00, can this be reopened, or would you rather have a fresh issue for the remaining slice?

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7142375992 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1674#issuecomment-7142375992). Originally posted by [mumba17](https://github.com/mumba17) on 2026-11-24T19:38:07Z. --- This issue was closed at 17:07 by the commit for the SMEM `off` fix (#1676). The compressed-export deliverable above is still open: on `main` at `ecc6e6ce`, `exp mrt0 v0, v0, off, off done compr vm` is still refused as `operand 'off'`. **Local count:** on an RTX 3090 with a warm cache from the first-run setup through the post-confirm load, 16 of 110 refused pipelines stop at this export, and nothing earlier refuses them. **Claiming the deliverable as written above:** - the translator records the channel mask per render target from the `off` pairs and an explicit `en:` mask; - the manifest carries the mask; - the runtime sets `RenderTargetWriteMask` from it when the console blend state gives no `CB_TARGET_MASK`. **Tests:** - start from synthetic encoded EXP instructions through `decode()`; - check the lowered HLSL and the recorded mask; - check on the runtime side that a channel outside the mask is not written. **Refusals kept:** packed-integer `compr`, unnamed formats, and masks that cannot be represented. @R0Y00, can this be reopened, or would you rather have a fresh issue for the remaining slice? AI-assisted (Claude Code).
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#1667
No description provided.