shader: keep a mesh v_cvt_f16_f32 high half only where it is defined (Part of #3703) #3862

Merged
mumba17 merged 2 commits from upstream-pr/3862 into main 2026-12-02 15:32:42 +00:00
mumba17 commented 2026-12-02 15:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-02T15:02:09Z.


Part of #3703 (claim: https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7349088746).

Problem

On gfx10, v_cvt_f16_f32 writes the low half of its destination and keeps the high half. The shared ALU builds the merged word from read(i.dst), which needs the whole old register. In a mesh program, when the destination has no value on one incoming path, or was never written, the conversion is refused with graphics register undefined on an incoming path or unproven mesh entry register N, even if nothing ever reads the high half.

Change

Under graphics_half_writes (the mesh frontend), the non-SDWA v_cvt_f16_f32 uses the rule v_fma_mixlo_f16 already uses. The high half is kept only where it is defined (graphics_bits), and the result is recorded as defined in 0xffff plus those bits. A later read that needs the undefined high half is still refused by read_storage with graphics register read includes undefined bits. Paths without graphics_half_writes and the SDWA forms are unchanged.

Tests (native_direct_mesh)

  • cvt-f16-over-widen-low-half: v10 has no value on one path after a widened EXEC. v_cvt_f16_f32 v10 then v_pack_b32_f16 of its low half translates, with no merge of an old high half.
  • cvt-f16-over-widen-full-read and cvt-f16-over-widen-high-half (op_sel): a whole-word read or a high-half read of that v10 is refused with graphics register read includes undefined bits: 266.
  • v-cvt-f16-f32-unproven-destination becomes v-cvt-f16-f32-unwritten-destination. The conversion into a never-written v5, which the program overwrites before any read, now translates. The refusal it pinned came from reading the whole old word, and the cases above now cover the high-half reads.

Census

A native Mesh86 capture on main 5770f14e (RTX 3090, 600 s, X2W_REFUSE_FIXED_MESH=1 X2W_NATIVE_MESH86=1) gives 6,685 distinct .m86 programs. Each went through compile_dxil … gfx1013-container-ms-texture-heap on main + #3710 + #3760 + #3790, with #3851 and #3852 applied so it builds.

  • Without this change: 1,786 translate. 96 stop at undefined on an incoming path, and in 82 of them the instruction is this conversion.
  • With it: 1,787 translate, 0 lost. All 82 move past this conversion. Their next first refusals are owned elsewhere: s_load_dwordx4 25 (#3835), D16 19 (#3836), v_cmpx_lt_f32 15 and v_cvt_f32_f16 11 (#3666), v_readfirstlane_b32 5 (#3842), packed rows 5, v_pack_b32_f16 constant 1. The 15 that remain at undefined on an incoming path are v_fmac_f32 / v_mul_legacy_f32 shapes and are not part of this PR.

Counts only; request bytes stay local.

Checks

Windows 11 build 26300, MSVC (VS Build Tools 14.44), SDK/DXC 10.0.26100. ctest --preset pr on this commit + #3851 + #3852 (main does not build with MSVC until #3852): 280/283 pass. native_direct_mesh passes. The two local failures, native_compute_implicit_lod_controls and native_wave_virtual_derivative_controls, are the local SDK validator 1.7 vs DXIL 1.8, also on main. CI's Windows build will fail on the #3841 lambda capture until #3852 lands.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5609078750 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3862). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-02T15:02:09Z. --- Part of #3703 (claim: https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7349088746). ## Problem On gfx10, `v_cvt_f16_f32` writes the low half of its destination and keeps the high half. The shared ALU builds the merged word from `read(i.dst)`, which needs the whole old register. In a mesh program, when the destination has no value on one incoming path, or was never written, the conversion is refused with `graphics register undefined on an incoming path` or `unproven mesh entry register N`, even if nothing ever reads the high half. ## Change Under `graphics_half_writes` (the mesh frontend), the non-SDWA `v_cvt_f16_f32` uses the rule `v_fma_mixlo_f16` already uses. The high half is kept only where it is defined (`graphics_bits`), and the result is recorded as defined in `0xffff` plus those bits. A later read that needs the undefined high half is still refused by `read_storage` with `graphics register read includes undefined bits`. Paths without `graphics_half_writes` and the SDWA forms are unchanged. ## Tests (`native_direct_mesh`) - `cvt-f16-over-widen-low-half`: v10 has no value on one path after a widened EXEC. `v_cvt_f16_f32 v10` then `v_pack_b32_f16` of its low half translates, with no merge of an old high half. - `cvt-f16-over-widen-full-read` and `cvt-f16-over-widen-high-half` (op_sel): a whole-word read or a high-half read of that v10 is refused with `graphics register read includes undefined bits: 266`. - `v-cvt-f16-f32-unproven-destination` becomes `v-cvt-f16-f32-unwritten-destination`. The conversion into a never-written v5, which the program overwrites before any read, now translates. The refusal it pinned came from reading the whole old word, and the cases above now cover the high-half reads. ## Census A native Mesh86 capture on `main` `5770f14e` (RTX 3090, 600 s, `X2W_REFUSE_FIXED_MESH=1 X2W_NATIVE_MESH86=1`) gives 6,685 distinct `.m86` programs. Each went through `compile_dxil … gfx1013-container-ms-texture-heap` on `main` + #3710 + #3760 + #3790, with #3851 and #3852 applied so it builds. - Without this change: 1,786 translate. 96 stop at `undefined on an incoming path`, and in 82 of them the instruction is this conversion. - With it: 1,787 translate, 0 lost. All 82 move past this conversion. Their next first refusals are owned elsewhere: `s_load_dwordx4` 25 (#3835), D16 19 (#3836), `v_cmpx_lt_f32` 15 and `v_cvt_f32_f16` 11 (#3666), `v_readfirstlane_b32` 5 (#3842), packed rows 5, `v_pack_b32_f16` constant 1. The 15 that remain at `undefined on an incoming path` are `v_fmac_f32` / `v_mul_legacy_f32` shapes and are not part of this PR. Counts only; request bytes stay local. ## Checks Windows 11 build 26300, MSVC (VS Build Tools 14.44), SDK/DXC 10.0.26100. `ctest --preset pr` on this commit + #3851 + #3852 (`main` does not build with MSVC until #3852): 280/283 pass. `native_direct_mesh` passes. The two local failures, `native_compute_implicit_lod_controls` and `native_wave_virtual_derivative_controls`, are the local SDK validator 1.7 vs DXIL 1.8, also on `main`. CI's Windows build will fail on the #3841 lambda capture until #3852 lands. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0Y00 commented 2026-12-02 15:26:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T15:26:19Z.

Review: APPROVED


Independent Windows/MSVC Debug review and build at 8a4aa8ee (after updating from main). cmake --build --preset dev --target compile_dxil passed. ctest --preset dev --no-tests=error -j 1 -R '^native_direct_(mesh|container)$' --output-on-failure passed 2/2. The mesh fixture accepts the defined low half after the widening join and refuses both high-half and whole-word consumers when the high half is undefined.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6153835189 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3862#pullrequestreview-6153835189). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T15:26:19Z. **Review:** APPROVED --- Independent Windows/MSVC Debug review and build at 8a4aa8ee (after updating from main). `cmake --build --preset dev --target compile_dxil` passed. `ctest --preset dev --no-tests=error -j 1 -R '^native_direct_(mesh|container)$' --output-on-failure` passed 2/2. The mesh fixture accepts the defined low half after the widening join and refuses both high-half and whole-word consumers when the high half is undefined.
Sign in to join this conversation.
No reviewers
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!3862
No description provided.