shader: lower the binary64 conversion forms #3628

Merged
lambirou merged 4 commits from upstream-pr/3628 into main 2026-12-03 12:22:54 +00:00
lambirou commented 2026-11-30 17:21:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T17:21:12Z.


Part of the f64 slice (P5).

This adds the five binary64 conversion forms: v_cvt_f64_i32_e64, v_cvt_f64_u32_e64, v_cvt_i32_f64_e64, v_cvt_u32_f64_e64 and v_cvt_f32_f64_e64.

  • int32/uint32 to f64 is exact: the translator builds both words from uint operations (sign bit, magnitude, exponent 1023 + highest-set-bit index, fraction bits), with no double, asdouble or rounding mode. Zero gives +0.0 and INT_MIN gives 0xc1e00000_00000000.
  • f64 to int32/uint32 truncates toward zero and refuses NaN, infinity and out-of-range values; f64 to f32 rounds to nearest even, with overflow to infinity and the subnormal range following the entry denormal profile.
  • Refusals: source modifiers, clamp/omod, DPP/SDWA, a destination that is not a two-register VGPR pair, an untracked or multi-dword source, and any use inside a masked region.

Tests

  • pixel_aot_cvt_f64_e64_warp and _hardware pass on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010).
  • The draw exports the pair words through the lossless R32G32B32A32_UINT readback and compares them with Python struct.pack('<d', ...); sentinels around the pair catch writes outside it. The rows cover 0, INT_MIN/MAX, -1, UINT_MAX and neighbours, 2^24 ± 1, 0x3f800000/0xbf800000 and the f64→f32 tie/overflow/subnormal cases; the mutations mismatch on both adapters.
  • form_coverage_check.py pins exactly the five forms and keeps the other f64 forms uncovered; the neighbouring draw-cvt-f64-* tests still pass.
  • Expected delta: +5 forms on gfx1013 and +5 on gfx1030. After the other open PRs and this one, the table reaches 1,738/1,968 and 1,640/1,863.

Limits

The desktop draws prove the translated shaders, not gfx1013 or the console. Binary64 arithmetic beyond these conversions remains unsupported. The high half of a 32-bit destination is not observed. No console measurement was made.

AI-assisted.

Merge with origin/main (2026-12-01)

Merged origin/main at a3bfd019 into this branch; head is c3e464d0. The shared CMake and test files keep both the #3607/#3623 additions and the PR additions. Local post-merge: pixel_aot_check.py, form_coverage_check.py and rdna2_tools_check.py pass (163 tests, 19 skips); CTest pixel_aot_cvt_f64_e64_warp and pixel_aot_f64_minmax_ldexp_warp pass.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5570207738 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3628). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-30T17:21:12Z. --- Part of the f64 slice (P5). This adds the five binary64 conversion forms: `v_cvt_f64_i32_e64`, `v_cvt_f64_u32_e64`, `v_cvt_i32_f64_e64`, `v_cvt_u32_f64_e64` and `v_cvt_f32_f64_e64`. - int32/uint32 to f64 is exact: the translator builds both words from `uint` operations (sign bit, magnitude, exponent 1023 + highest-set-bit index, fraction bits), with no `double`, `asdouble` or rounding mode. Zero gives +0.0 and INT_MIN gives 0xc1e00000_00000000. - f64 to int32/uint32 truncates toward zero and refuses NaN, infinity and out-of-range values; f64 to f32 rounds to nearest even, with overflow to infinity and the subnormal range following the entry denormal profile. - Refusals: source modifiers, clamp/omod, DPP/SDWA, a destination that is not a two-register VGPR pair, an untracked or multi-dword source, and any use inside a masked region. ## Tests - `pixel_aot_cvt_f64_e64_warp` and `_hardware` pass on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010). - The draw exports the pair words through the lossless `R32G32B32A32_UINT` readback and compares them with Python `struct.pack('<d', ...)`; sentinels around the pair catch writes outside it. The rows cover 0, INT_MIN/MAX, -1, UINT_MAX and neighbours, 2^24 ± 1, 0x3f800000/0xbf800000 and the f64→f32 tie/overflow/subnormal cases; the mutations mismatch on both adapters. - `form_coverage_check.py` pins exactly the five forms and keeps the other f64 forms uncovered; the neighbouring `draw-cvt-f64-*` tests still pass. - Expected delta: **+5 forms on gfx1013 and +5 on gfx1030**. After the other open PRs and this one, the table reaches **1,738/1,968** and **1,640/1,863**. ## Limits The desktop draws prove the translated shaders, not gfx1013 or the console. Binary64 arithmetic beyond these conversions remains unsupported. The high half of a 32-bit destination is not observed. No console measurement was made. AI-assisted. ## Merge with origin/main (2026-12-01) Merged `origin/main` at `a3bfd019` into this branch; head is `c3e464d0`. The shared CMake and test files keep both the #3607/#3623 additions and the PR additions. Local post-merge: `pixel_aot_check.py`, `form_coverage_check.py` and `rdna2_tools_check.py` pass (163 tests, 19 skips); CTest `pixel_aot_cvt_f64_e64_warp` and `pixel_aot_f64_minmax_ldexp_warp` pass.
lukaslw-lab commented 2026-11-30 20:32:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T20:32:05Z.

Review: COMMENTED


Reviewed 781883a2 by reading the diff; not built or run.

Verdict: comment. No MUST. The arithmetic is right. Two SHOULDs on the new rounding slice of v_cvt_f32_f64 are worth settling before merge, because they change what #1606 approved.

  • SHOULD cvt_f32_f64_rne_bits refuses a nonzero binary32 subnormal result because MODE[5:4] has no declared profile (tools/pixel_aot.py:2872). It still accepts a value just below 2^-126 that rounds up to the smallest normal (:2910, e.g. 2^-126 − 2^-150). Whether that case gives 0x00800000 or a flushed zero depends on the same unmodelled binary32 denormal/flush mode, and on when the hardware detects tininess. For consistency with the docstring's reason, refuse it as well, or state the no-flush assumption in the docs.
  • SHOULD The docs still call this a "mode-independent slice (the slice the maintainer approved in #1606 and the follow-up that added rounding)". It also says "the shader reads neither the rounding nor the denormal mode". Rounding makes the result depend on the rounding mode. It is correct only because every accepted MODE write keeps MODE[1:0] at nearest even, and because the existing check (:4787) refuses any v_*_f64 form under round-toward-zero in MODE[3:2]. Please state that dependency. #1606 approved an exact-only slice, so widening it to rounding needs the maintainer's own sign-off rather than being described as already approved.
  • Checked, no finding:
    • RNE narrowing to 24 bits with a carry into the exponent, overflow to ±Inf from the 2^128 − 2^103 midpoint, f64 subnormal inputs to a signed zero, and the 2^-150 tie to even zero.
    • cvt_int_f64_bits: truncation toward zero, with NaN/Inf and out-of-range values refused.
    • f64_conversion_source: proven records, two statically known words, or an aligned SGPR pair (_e64 only). Modifiers fall through to the refusal.

Tests: the unit asserts pin the midpoints listed above. The draw compares the pair words against struct.pack, with sentinels around the pair. The controls run in the Linux LLVM job (passed). pixel_aot_cvt_f64_e64_{warp,hardware} are not in the Windows pr preset filter, so the draw has only the author's WARP + RX 9060 XT run. All results are translation-time constants, so the draw checks the emitted words, not a runtime path.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6120038920 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3628#pullrequestreview-6120038920). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-30T20:32:05Z. **Review:** COMMENTED --- Reviewed `781883a2` by reading the diff; not built or run. **Verdict: comment.** No MUST. The arithmetic is right. Two SHOULDs on the new rounding slice of `v_cvt_f32_f64` are worth settling before merge, because they change what #1606 approved. - **SHOULD** `cvt_f32_f64_rne_bits` refuses a nonzero binary32 subnormal result because MODE[5:4] has no declared profile (`tools/pixel_aot.py:2872`). It still accepts a value just below 2^-126 that rounds *up* to the smallest normal (`:2910`, e.g. 2^-126 − 2^-150). Whether that case gives `0x00800000` or a flushed zero depends on the same unmodelled binary32 denormal/flush mode, and on when the hardware detects tininess. For consistency with the docstring's reason, refuse it as well, or state the no-flush assumption in the docs. - **SHOULD** The docs still call this a "mode-independent slice (the slice the maintainer approved in #1606 and the follow-up that added rounding)". It also says "the shader reads neither the rounding nor the denormal mode". Rounding makes the result depend on the rounding mode. It is correct only because every accepted MODE write keeps MODE[1:0] at nearest even, and because the existing check (`:4787`) refuses any `v_*_f64` form under round-toward-zero in MODE[3:2]. Please state that dependency. #1606 approved an exact-only slice, so widening it to rounding needs the maintainer's own sign-off rather than being described as already approved. - Checked, no finding: - RNE narrowing to 24 bits with a carry into the exponent, overflow to ±Inf from the 2^128 − 2^103 midpoint, f64 subnormal inputs to a signed zero, and the 2^-150 tie to even zero. - `cvt_int_f64_bits`: truncation toward zero, with NaN/Inf and out-of-range values refused. - `f64_conversion_source`: proven records, two statically known words, or an aligned SGPR pair (`_e64` only). Modifiers fall through to the refusal. Tests: the unit asserts pin the midpoints listed above. The draw compares the pair words against `struct.pack`, with sentinels around the pair. The controls run in the Linux LLVM job (passed). `pixel_aot_cvt_f64_e64_{warp,hardware}` are not in the Windows `pr` preset filter, so the draw has only the author's WARP + RX 9060 XT run. All results are translation-time constants, so the draw checks the emitted words, not a runtime path.
R0Y00 commented 2026-12-02 23:56:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T23:56:16Z.

Review: CHANGES_REQUESTED


The green Linux check is misleading on e4dcf15f9. I ran python -B tests/form_coverage_check.py from that exact head and got exit 0 with no output. The file no longer has a module-level entry point. Its coverage call list and success print are indented inside check_f16_pack_cndmask_forms, and the list includes a call to that same function. Nine existing check definitions also disappear relative to main, including the f64 FMA/round, SMEM atomics and multiply-literal coverage. Please retain main's existing registrations, wire the new f64 conversion check into the actual entry point, and rerun the whole coverage script. A deliberately failing existing assertion is a useful negative control for the restored entry point.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6161226529 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3628#pullrequestreview-6161226529). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T23:56:16Z. **Review:** CHANGES_REQUESTED --- The green Linux check is misleading on `e4dcf15f9`. I ran `python -B tests/form_coverage_check.py` from that exact head and got exit 0 with no output. The file no longer has a module-level entry point. Its coverage call list and success print are indented inside `check_f16_pack_cndmask_forms`, and the list includes a call to that same function. Nine existing check definitions also disappear relative to main, including the f64 FMA/round, SMEM atomics and multiply-literal coverage. Please retain main's existing registrations, wire the new f64 conversion check into the actual entry point, and rerun the whole coverage script. A deliberately failing existing assertion is a useful negative control for the restored entry point.
R0Y00 commented 2026-12-03 01:49:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:49:17Z.

Review: COMMENTED


I rechecked the new head against current main. The module-level entry point and the previously missing function definitions are back, and the binary64 cases are in the active call list. The list still drops check_mullit_coverage even though that function remains defined. Please restore that call and rerun the full test directly before re-review.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6162311558 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3628#pullrequestreview-6162311558). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T01:49:17Z. **Review:** COMMENTED --- I rechecked the new head against current main. The module-level entry point and the previously missing function definitions are back, and the binary64 cases are in the active call list. The list still drops check_mullit_coverage even though that function remains defined. Please restore that call and rerun the full test directly before re-review.
R0Y00 commented 2026-12-03 12:22:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T12:22:15Z.

Review: APPROVED


Re-reviewed ab623577. The module-level coverage entry point includes the binary64 conversions and retains MULLIT. The full form coverage script passed in the project Python environment. Injecting a failure inside check_mullit_coverage failed the entry point at that exact assertion. Independent MSVC Debug with SDK DXC on Windows build 26300: draw-cvt-f64-e64 passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 with no skips. This resolves my previous changes request.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6169705757 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3628#pullrequestreview-6169705757). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T12:22:15Z. **Review:** APPROVED --- Re-reviewed ab623577. The module-level coverage entry point includes the binary64 conversions and retains MULLIT. The full form coverage script passed in the project Python environment. Injecting a failure inside check_mullit_coverage failed the entry point at that exact assertion. Independent MSVC Debug with SDK DXC on Windows build 26300: draw-cvt-f64-e64 passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 with no skips. This resolves my previous changes request.
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!3628
No description provided.