shader: lower v_cvt_f16_u16, v_cvt_f16_i16, v_cvt_u16_f16 and v_cvt_i16_f16 in the direct compute path #3159

Merged
legacy-code-archaeologist merged 2 commits from upstream-pr/3159 into main 2026-11-27 20:43:02 +00:00
legacy-code-archaeologist commented 2026-11-27 19:09:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T19:09:19Z.


Lowers v_cvt_f16_u16, v_cvt_f16_i16, v_cvt_u16_f16, and v_cvt_i16_f16 (VOP1 and VOP3A) in the direct C++ compute path (src/gfx1013_direct_compute.inl), preserving D[31:16] and enforcing the binary16 MODE contract via half_binary.

Verification

Measured on Windows 10.0.26100 (dev preset) at upstream/main 429f11d5 + 6772a597:

  • ctest --preset dev --no-tests=error -R '^native_cvt_f16_i16_' -V:
    • native_cvt_f16_i16_ir (passed, 1.09s): evaluates DXIL IR via native_compute_ir_dump across 82 conversion cases (VGPR, SGPR, literal, inline ints/floats, VOP3 clamp/abs/neg/-|x|, RNE ties, saturation, subnormals, infinities, NaNs, non-zero upper halves) and 38 refusals (DPP, SDWA, omod, op_sel, illegal abs/neg/clamp, src1, and MODE writes).
    • native_cvt_f16_i16_controls (passed, 3.84s): compiles all 82 conversions to DXIL via compile_dxil and verifies all 38 refusals.
    • native_cvt_f16_i16_hardware (skipped, exit 77): Quadro M1000M does not support shader model 6.6 with wave32, so GPU readback is not measured.
  • ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 47/47 passed (54.43s).
  • python -B tests/docs_links_check.py: passed (101 Markdown files, 589 links).
  • Broken-lowering sensitivity check: 5 deliberate mutations (zero_high_half, drop_ordered_nan, swap_signed, drop_clamp, wrong_inline_float) each failed native_cvt_f16_i16_ir (exit 1).

Fixes #3148
Refs #2935

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5531836812 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3159). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-27T19:09:19Z. --- Lowers `v_cvt_f16_u16`, `v_cvt_f16_i16`, `v_cvt_u16_f16`, and `v_cvt_i16_f16` (VOP1 and VOP3A) in the direct C++ compute path (`src/gfx1013_direct_compute.inl`), preserving `D[31:16]` and enforcing the binary16 MODE contract via `half_binary`. ## Verification Measured on Windows 10.0.26100 (`dev` preset) at `upstream/main` `429f11d5` + `6772a597`: - `ctest --preset dev --no-tests=error -R '^native_cvt_f16_i16_' -V`: - `native_cvt_f16_i16_ir` (**passed**, `1.09s`): evaluates DXIL IR via `native_compute_ir_dump` across 82 conversion cases (VGPR, SGPR, literal, inline ints/floats, VOP3 `clamp`/`abs`/`neg`/`-|x|`, RNE ties, saturation, subnormals, infinities, NaNs, non-zero upper halves) and 38 refusals (DPP, SDWA, `omod`, `op_sel`, illegal `abs`/`neg`/`clamp`, `src1`, and MODE writes). - `native_cvt_f16_i16_controls` (**passed**, `3.84s`): compiles all 82 conversions to DXIL via `compile_dxil` and verifies all 38 refusals. - `native_cvt_f16_i16_hardware` (**skipped**, exit `77`): Quadro M1000M does not support shader model 6.6 with wave32, so GPU readback is not measured. - `ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure`: **47/47 passed** (`54.43s`). - `python -B tests/docs_links_check.py`: **passed** (101 Markdown files, 589 links). - Broken-lowering sensitivity check: 5 deliberate mutations (`zero_high_half`, `drop_ordered_nan`, `swap_signed`, `drop_clamp`, `wrong_inline_float`) each failed `native_cvt_f16_i16_ir` (exit `1`). Fixes #3148 Refs #2935 AI-assisted.
tedin7 commented 2026-11-27 20:42:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T20:42:48Z.

Review: COMMENTED


Review of 7adec5b78f (updated with main). Comment only.

The four conversions read inline float sources 240-248 as their binary16 values (the same nine constants as inline_half_words, which #3147 just made a shared member; the local halves[] copy here could use it in a follow-up), and literal and inline integer sources as their low 16 bits. f16 -> i16/u16 truncates through fptosi/fptoui only on an in-range value, saturates out-of-range values to the type bounds and maps NaN to 0; i16/u16 -> f16 goes through f32 and packed_half_rne, which is exact because every 16-bit integer is exact in f32. Unsupported forms (DPP, SDWA, omod, op_sel high half, modifiers on the integer source, an unknown rounding or denormal mode) are refused. native_cvt_f16_i16_ir checks 82 cases at the IR level without a GPU, so the semantics are covered on WARP hosts and in CI even though the _hardware leg skips.

src/gfx1013_direct_compute.inl is also changed on cpp-migration; this merges cleanly there and the native sweep passes on that merge (comment below).

Commands: git diff origin/main...pull/3159/head (read), git merge-tree --write-tree origin/cpp-migration pull/3159/head, plus the Windows commands in the comment below.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093174936 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3159#pullrequestreview-6093174936). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T20:42:48Z. **Review:** COMMENTED --- Review of 7adec5b78f8c0467765ef7857bb4db10be3ed5f5 (updated with main). Comment only. The four conversions read inline float sources 240-248 as their binary16 values (the same nine constants as `inline_half_words`, which #3147 just made a shared member; the local `halves[]` copy here could use it in a follow-up), and literal and inline integer sources as their low 16 bits. `f16 -> i16/u16` truncates through `fptosi`/`fptoui` only on an in-range value, saturates out-of-range values to the type bounds and maps NaN to 0; `i16/u16 -> f16` goes through f32 and `packed_half_rne`, which is exact because every 16-bit integer is exact in f32. Unsupported forms (DPP, SDWA, omod, op_sel high half, modifiers on the integer source, an unknown rounding or denormal mode) are refused. `native_cvt_f16_i16_ir` checks 82 cases at the IR level without a GPU, so the semantics are covered on WARP hosts and in CI even though the `_hardware` leg skips. `src/gfx1013_direct_compute.inl` is also changed on `cpp-migration`; this merges cleanly there and the native sweep passes on that merge (comment below). Commands: `git diff origin/main...pull/3159/head` (read), `git merge-tree --write-tree origin/cpp-migration pull/3159/head`, plus the Windows commands in the comment below. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-27 20:42:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T20:42:49Z.


Windows Server 2025 verification of 7adec5b78f8c0467765ef7857bb4db10be3ed5f5 (D3D12 WARP, MSVC 14.44.35207):

  • dev: cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump; ctest --preset dev -R <native sweep>: 100% tests passed out of 143 (84 passed, 59 hardware legs skipped), including native_cvt_f16_i16_ir and native_cvt_f16_i16_controls
  • release: same targets with --preset release; ctest --preset release -R <native sweep>: 100% tests passed out of 143 (84 passed, 59 skipped)
  • The same dev and release sweep on this head merged with cpp-migration (a0f67731): 100% tests passed out of 143 in both presets

<native sweep> = every native_* test except native_startup_request_cache_hardware, which fails on WARP-only hosts with or without this PR.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7227769071 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3159#issuecomment-7227769071). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T20:42:49Z. --- Windows Server 2025 verification of `7adec5b78f8c0467765ef7857bb4db10be3ed5f5` (D3D12 WARP, MSVC 14.44.35207): - dev: `cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump`; `ctest --preset dev -R <native sweep>`: 100% tests passed out of 143 (84 passed, 59 hardware legs skipped), including `native_cvt_f16_i16_ir` and `native_cvt_f16_i16_controls` - release: same targets with `--preset release`; `ctest --preset release -R <native sweep>`: 100% tests passed out of 143 (84 passed, 59 skipped) - The same dev and release sweep on this head merged with `cpp-migration` (`a0f67731`): 100% tests passed out of 143 in both presets `<native sweep>` = every `native_*` test except `native_startup_request_cache_hardware`, which fails on WARP-only hosts with or without this PR. AI-assisted; commands listed were executed locally.
xiaoqi72665 commented 2026-11-27 21:35:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by xiaoqi72665 on 2026-11-27T21:35:23Z.


@legacy-code-archaeologist Thanks for #3159. During #3185's rebase regression on 5b145ca, the stock conversion hardware fixture reached its last guard assertion and raised AttributeError: module 'native_f16_alu_check' has no attribute 'SENTINEL' (tests/native_cvt_f16_i16_check.py). The preceding 82 conversion comparisons across both groups passed. With an ignored local diagnostic copy comparing the entire 2064-DWORD buffer to the expected conversion positions plus 0x69696969 guards, RX 7900 XT and app-local WARP passed in both Debug and Release on Win10. Suggested minimal fix: construct the full expected buffer (including zeros in the actual guard check), rather than filtering zero words. IR and compile controls also passed. No changes to your files in #3185. AI-assisted, tested locally by Buhe.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228580104 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3159#issuecomment-7228580104). Originally posted by [xiaoqi72665](https://github.com/xiaoqi72665) on 2026-11-27T21:35:23Z. --- @legacy-code-archaeologist Thanks for #3159. During #3185's rebase regression on 5b145ca, the stock conversion hardware fixture reached its last guard assertion and raised `AttributeError: module 'native_f16_alu_check' has no attribute 'SENTINEL'` (tests/native_cvt_f16_i16_check.py). The preceding 82 conversion comparisons across both groups passed. With an ignored local diagnostic copy comparing the entire 2064-DWORD buffer to the expected conversion positions plus 0x69696969 guards, RX 7900 XT and app-local WARP passed in both Debug and Release on Win10. Suggested minimal fix: construct the full expected buffer (including zeros in the actual guard check), rather than filtering zero words. IR and compile controls also passed. No changes to your files in #3185. AI-assisted, tested locally by Buhe.
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!3159
No description provided.