shader: keep only defined bits under a mesh SDWA UNUSED_PRESERVE write (Part of #3703) #3941
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3941"
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-12-03T15:19:09Z.
Part of #3703 (the half-write slice of
graphics register undefined on an incoming path, left with us in https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7358494917).Problem
Since #3862, a mesh
v_cvt_f16_f32into a register that has no value on one incoming path (or was never written) defines only the low half. Programs then fill the high half with an SDWAv_cvt_f16_f32 … dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE.place_subwordbuilt that merge fromread(i.dst), which needs every bit of the old register, so the write was refused withgraphics register read includes undefined bits, although the two writes together define the whole register.Change
Under
graphics_half_writes(the mesh frontend),UNUSED_PRESERVEkeeps the other bits only where they are defined (graphics_bits), the rulev_cvt_f16_f32andv_fma_mixlo_f16/v_fma_mixhi_f16already use. The result is recorded as defined in the written bits plus the kept ones. A later read that needs a kept bit with no value is still refused byread_storage. Paths withoutgraphics_half_writes, andUNUSED_PAD/UNUSED_SEXT, are unchanged.Tests (
native_direct_mesh)cvt-f16-sdwa-high-over-low: v10 has no value on one path after a widened EXEC.v_cvt_f16_f32 v10writes the low half, the SDWA WORD_1 preserve conversion writes the high half, and a whole-word read of v10 translates. The output places the narrowed 0.5 above the narrowed 1.0 (shl … 16or'd withand … 65535).cvt-f16-sdwa-high-only: the same SDWA write with no low-half write first. A whole-word read is refused withgraphics register read includes undefined bits: 266.cvt-f16-sdwa-high-over-lowfails withgraphics register read includes undefined bits: 266.Census
Our native Mesh86 capture (RTX 3090, 600 s) gives 6,685 distinct
.m86programs, each run once throughcompile_dxil … gfx1013-container-ms-texture-heap.mainadfc0d94: 2,161 translate. 5 stop atgraphics register read includes undefined bits, all at this preserve write.unproven packed mesh signature rows(2) andunsupported packed vertex export(1). No other program's first refusal changes.Counts only; request bytes stay local.
Checks
Windows 11 build 26300, MSVC (VS Build Tools 14.44), SDK/DXC 10.0.26100.
ctest --preset pron this commit (rebased onmain4b2c8343): 346/348 pass,native_direct_meshincluded. The two local failures,native_compute_implicit_lod_controlsandnative_wave_virtual_derivative_controls, are the local SDK validator 1.7 vs DXIL 1.8 and fail onmaintoo. The census above was measured onadfc0d94and not rerun after the rebase.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T15:39:28Z.
Review: APPROVED
Independently reviewed
432d5075. The preserve merge masks out the bits being replaced and intersects the remaining bits with the available graphics SSA definition. The missing-low-half control still refuses the whole-register read, and the existing non-mesh path retains its full-word read.On Windows 11 with MSVC Debug I rebuilt compile_dxil and ran ctest --test-dir out/build/review --no-tests=error -R '^native_direct_mesh$' --output-on-failure (1/1 passed, no skips). Disabling only the new graphics preserve branch and rebuilding made cvt-f16-sdwa-high-over-low fail at +0x44 with “graphics register read includes undefined bits: 266”. The unmodified fixture also checks the negative case where no low half was ever defined. These verify compilation and emitted DXIL. The required Windows check passed.