shader: lower v_cvt_f64_i32 and v_cvt_f64_u32 in direct compute path #3367

Merged
R0D4X merged 1 commit from upstream-pr/3367 into main 2026-11-28 19:19:07 +00:00
R0D4X commented 2026-11-28 14:34:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-28T14:34:04Z.


Fixes #3363. Refs #2935.

Summary

  • Lower VOP1/VOP3A v_cvt_f64_i32 (0x04 / 0x184) and v_cvt_f64_u32 (0x16 / 0x196) in the native direct-DXIL compute path (src/gfx1013_direct_compute.inl):
    • Constructs the exact IEEE-754 binary64 word pair v[d:d+1] using pure 32-bit integer arithmetic and dx.op.unaryBits.i32(33) (FirstbitHi), requiring neither DoublePrecisionFloatShaderOps nor Int64ShaderOps.
    • Supports VOP1 and VOP3A encodings with VGPR, SGPR, inline-integer, and 32-bit literal sources (including overlapping D[0] == S0).
    • Refuses pixel_stage, graphics_input, abs, neg, clamp, omod, op_sel, subword, dpp, unused VOP3 src1/src2, dst == v255, and inline-float sources.
  • Register both instructions as 64-bit VGPR pair writes in clear_vector_spills (src/gfx1013_compute_native.cpp).
  • Add tests/native_cvt_f64_int_check.py (ir CPU evaluation + controls + hardware), tests/cmake/native_f64_int_cvt.cmake, and docs/experiments/native-cvt-f64-int.md.

Verification

  • Commit: 7096dc9d
  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK / DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), D3D12 debug layer off.
  • Commands & results:
    • cmake --build --preset dev --target native_compute_ir_dump compile_dxil native_store_replay & release: succeeded.
    • ctest --preset dev --no-tests=error -R '^native_cvt_f64_int_' -V: 3/3 passed (0 skipped); 32 CPU-evaluated IR words match struct.pack('<d'), 8 refusals verified, 2064 hardware readback words matched.
    • ctest --preset release --no-tests=error -R '^native_cvt_f64_int_' -V: 3/3 passed (0 skipped); all 2064 hardware words matched.
    • tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check: passed.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5541194615 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3367). Originally posted by [R0D4X](https://github.com/R0D4X) on 2026-11-28T14:34:04Z. --- Fixes #3363. Refs #2935. ### Summary - Lower VOP1/VOP3A `v_cvt_f64_i32` (`0x04` / `0x184`) and `v_cvt_f64_u32` (`0x16` / `0x196`) in the native direct-DXIL compute path (`src/gfx1013_direct_compute.inl`): - Constructs the exact IEEE-754 binary64 word pair `v[d:d+1]` using pure 32-bit integer arithmetic and `dx.op.unaryBits.i32(33)` (`FirstbitHi`), requiring neither `DoublePrecisionFloatShaderOps` nor `Int64ShaderOps`. - Supports VOP1 and VOP3A encodings with VGPR, SGPR, inline-integer, and 32-bit literal sources (including overlapping `D[0] == S0`). - Refuses `pixel_stage`, `graphics_input`, `abs`, `neg`, `clamp`, `omod`, `op_sel`, `subword`, `dpp`, unused VOP3 `src1`/`src2`, `dst == v255`, and inline-float sources. - Register both instructions as 64-bit VGPR pair writes in `clear_vector_spills` (`src/gfx1013_compute_native.cpp`). - Add `tests/native_cvt_f64_int_check.py` (`ir` CPU evaluation + `controls` + `hardware`), `tests/cmake/native_f64_int_cvt.cmake`, and `docs/experiments/native-cvt-f64-int.md`. ### Verification - Commit: `7096dc9d` - Environment: Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230`, Windows SDK / DXC `10.0.26100.0`, NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2140`), D3D12 debug layer off. - Commands & results: - `cmake --build --preset dev --target native_compute_ir_dump compile_dxil native_store_replay` & `release`: succeeded. - `ctest --preset dev --no-tests=error -R '^native_cvt_f64_int_' -V`: 3/3 passed (0 skipped); 32 CPU-evaluated IR words match `struct.pack('<d')`, 8 refusals verified, 2064 hardware readback words matched. - `ctest --preset release --no-tests=error -R '^native_cvt_f64_int_' -V`: 3/3 passed (0 skipped); all 2064 hardware words matched. - `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `git diff --check`: passed.
Leyukaka commented 2026-11-28 19:11:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T19:11:22Z.

Review: APPROVED


GPU review of 7096dc9d.

  • Every i32/u32 is exact in binary64. The normalisation splits the 31 fraction bits into 20 in the high word and 11 in the low word; INT_MIN, UINT_MAX and 0 are right. A v255 destination pair, abs/neg/clamp/omod/op_sel and inline float sources are refused.
  • Run here in Windows Sandbox, network off, vGPU, Windows 11 build 26300 host, release build of main f2972840 with this PR and 17 other open PRs merged locally: native_cvt_f64_int_ir, _controls and _hardware pass. Changing the exponent bias 1023 to 1022 makes _ir and _hardware fail.

Approve.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6099696650 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3367#pullrequestreview-6099696650). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T19:11:22Z. **Review:** APPROVED --- GPU review of `7096dc9d`. - Every i32/u32 is exact in binary64. The normalisation splits the 31 fraction bits into 20 in the high word and 11 in the low word; `INT_MIN`, `UINT_MAX` and 0 are right. A v255 destination pair, abs/neg/clamp/omod/op_sel and inline float sources are refused. - Run here in Windows Sandbox, network off, vGPU, Windows 11 build 26300 host, release build of `main` `f2972840` with this PR and 17 other open PRs merged locally: `native_cvt_f64_int_ir`, `_controls` and `_hardware` pass. Changing the exponent bias `1023` to `1022` makes `_ir` and `_hardware` fail. Approve.
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!3367
No description provided.