shader: lower v_cvt_i32_f64 and v_cvt_u32_f64 in direct compute path #3371

Merged
R0D4X merged 1 commit from upstream-pr/3371 into main 2026-11-28 19:27:50 +00:00
R0D4X commented 2026-11-28 14:53:44 +00:00 (Migrated from github.com)

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


Fixes #3370. Refs #2935.

Summary

  • Lower VOP1/VOP3A v_cvt_i32_f64 (0x03 / 0x183) and v_cvt_u32_f64 (0x15 / 0x195) in the native direct-DXIL compute path (src/gfx1013_direct_compute.inl):
    • Converts a 64-bit binary64 source pair (v[a:a+1] or even s[a:a+1]) to a saturated 32-bit signed or unsigned integer (truncation toward zero, NaN -> 0, signed saturation to [INT32_MIN, INT32_MAX], unsigned saturation to [0, UINT32_MAX]) using pure 32-bit integer arithmetic, requiring neither DoublePrecisionFloatShaderOps nor Int64ShaderOps.
    • Supports VOP1 and VOP3A encodings with VOP3A abs/neg on the binary64 source sign; refuses pixel_stage, graphics_input, clamp, omod, op_sel, subword, dpp, unused VOP3 sources/modifiers, and non-pair S0.
  • Add tests/native_cvt_int_f64_check.py (ir CPU evaluation + controls + hardware), tests/cmake/native_int_f64_cvt.cmake, and docs/experiments/native-cvt-int-f64.md.

Verification

  • Commit: 7d8ada1e
  • 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_int_f64_' -V: 3/3 passed (0 skipped); 32 CPU-evaluated IR words + 8 refusals + 2064 hardware readback words matched.
    • ctest --preset release --no-tests=error -R '^native_cvt_int_f64_' -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:5541365936 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3371). Originally posted by [R0D4X](https://github.com/R0D4X) on 2026-11-28T14:53:44Z. --- Fixes #3370. Refs #2935. ### Summary - Lower VOP1/VOP3A `v_cvt_i32_f64` (`0x03` / `0x183`) and `v_cvt_u32_f64` (`0x15` / `0x195`) in the native direct-DXIL compute path (`src/gfx1013_direct_compute.inl`): - Converts a 64-bit binary64 source pair (`v[a:a+1]` or even `s[a:a+1]`) to a saturated 32-bit signed or unsigned integer (truncation toward zero, `NaN -> 0`, signed saturation to `[INT32_MIN, INT32_MAX]`, unsigned saturation to `[0, UINT32_MAX]`) using pure 32-bit integer arithmetic, requiring neither `DoublePrecisionFloatShaderOps` nor `Int64ShaderOps`. - Supports VOP1 and VOP3A encodings with VOP3A `abs`/`neg` on the binary64 source sign; refuses `pixel_stage`, `graphics_input`, `clamp`, `omod`, `op_sel`, `subword`, `dpp`, unused VOP3 sources/modifiers, and non-pair `S0`. - Add `tests/native_cvt_int_f64_check.py` (`ir` CPU evaluation + `controls` + `hardware`), `tests/cmake/native_int_f64_cvt.cmake`, and `docs/experiments/native-cvt-int-f64.md`. ### Verification - Commit: `7d8ada1e` - 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_int_f64_' -V`: 3/3 passed (0 skipped); 32 CPU-evaluated IR words + 8 refusals + 2064 hardware readback words matched. - `ctest --preset release --no-tests=error -R '^native_cvt_int_f64_' -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:27:47 +00:00 (Migrated from github.com)

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

Review: APPROVED


GPU review of 7d8ada1e.

  • Truncation toward zero, NaN → 0, saturation and the 1054 / 1055 exponent bounds are correct. The _ir test runs the emitted code on the CPU, so it checks values.
  • 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_int_f64_ir, _controls and _hardware pass. Changing the signed bound 1054 to 1055 makes _ir and _hardware fail.

Not covered: no ±Inf case and no input ≥ 2^32, so removing the u32 saturation would pass; the lo != 0 NaN term (lo = 1, hi = 0x7FF00000) is also untested.

Approve.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6099751789 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3371#pullrequestreview-6099751789). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T19:27:47Z. **Review:** APPROVED --- GPU review of `7d8ada1e`. - Truncation toward zero, NaN → 0, saturation and the 1054 / 1055 exponent bounds are correct. The `_ir` test runs the emitted code on the CPU, so it checks values. - 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_int_f64_ir`, `_controls` and `_hardware` pass. Changing the signed bound `1054` to `1055` makes `_ir` and `_hardware` fail. Not covered: no ±Inf case and no input ≥ 2^32, so removing the u32 saturation would pass; the `lo != 0` NaN term (`lo = 1`, `hi = 0x7FF00000`) is also untested. 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!3371
No description provided.