startup: carry partial colour export masks to the pipeline write mask #2051
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2058"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-24T23:45:01Z.
Closes the open deliverable of #1674 (the issue was auto-closed by the SMEM
offcommit; the compressed-export part was still refused). Claimed in https://github.com/R0Y00/Xbox2Windows/issues/1674#issuecomment-7142375992.Problem
A colour export leaves its
offchannels unwritten, so the render target keeps what it held there.gfx2hlslrefused the compressed form (exp mrt0 v0, v0, off, off done compr vm). It also lowered uncompressedoffchannels as0.0into a fullfloat4. Every target keepsD3D12_COLOR_WRITE_ENABLE_ALL(CB_TARGET_MASKis not located), so substituting zero overwrites channels the console shader leaves alone. #1693 was closed for this reason.Change
One behaviour: the channels an export writes now reach the pipeline write mask.
tools/startup/gfx2hlsl.py:mrtNexport records its written channels: bit c is set when channel c is notoff.wmask <target> 0x<mask>for any target that is not fully written. Full masks write no line, so existing manifests are unchanged.0x3), 2–3 (0xC) or both.src/startup_stubs/export_write_mask.h(new):wmasklines. It refuses a target above 7, a mask of 0 or above0xF, any other form, and a second line for the same target. A refused line rejects the manifest.apply_export_write_masks()ANDs each mask into the target'sRenderTargetWriteMask. A shared blend state (IndependentBlendEnableFALSE) is first expanded to eight equal entries.src/startup_stubs/d3d12_draw.inl: reads the line and applies the masks inpipeline_for()after the console blend state.Refusals kept
These match
pixel_aot(#398, #434):en:mask that is not a whole pair (it fell through the export regex before, with anAttributeError);Not in this slice, as #1674 states: the value a partially written channel should take.
Overlap
#2034 lowers the same compressed
offform by exporting zero without a mask. That is the form #1674 describes as unsafe. With this PR the zeros are still emitted, but the write mask keeps them out of the target.Tests
startup_gfx2hlsl_export_maskdecode()and a full translation with the recordedstartup_flat_paramvertex stage: disassembly forms, lowered HLSL andwmasklines for both pairs, both pairs, uncompressed partial, two targets, and every refusal above.--mutate drop-maskdrops the manifest lines: 4 mask checks fail.startup_export_write_mask0x9 & 0x3 = 0x1).--mutate shared-blendskips the expansion.startup_export_write_mask_{warp,hardware}wmaskline applied to an opaque PSO. A constant source drawn over a cleared RGBA32F target. Masks0x3,0xC,0x5,0x8: unwritten channels keep the cleared value, written channels take the source, exactly.startup_export_write_mask_unmasked_*draws without the mask; all 4 cases must differ.The hardware readback for
0x3is0.75 0.5 1 0.0625: the source0.75 0.5, and the cleared1 0.0625.Environment:
mainat06cdc47d, Windows 11 build 26300, MSVC 14.44 Release, RTX 3090 (driver 32.0.16.1664) and WARP.Real cache: in a local startup cache, 16 refused pipeline requests stopped at this export. With this change they pass it. They then stop at a separate problem in how their two stages are ordered, which I will report separately; this PR does not change that.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-24T23:45:37Z.
Full non-hardware suite on
03dee932(this branch onmain06cdc47d), Windows 11 26300, MSVC 14.44 Release:ctest --preset release -E _hardware -j 8-> 942/942 passed (454 s). The new_hardwarewrite-mask tests pass on the RTX 3090 as listed above.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T00:07:17Z.
I pushed three fixes for the production path. Both cache writers now use revision 7, so the pre-fix zero-filled manifests cannot win the lookup. The reader rejects signed, oversized and malformed mask tokens. The pipeline preserves a legal shared logic operation when the masks agree, and refuses incompatible per-target masks before desktop PSO creation. Windows Release passed all 14 selected blend and export checks, including hardware and WARP pixel readback and the unmasked controls. The separate RTX 3090 startup report used a local slot 148 stand-in.