recomp: omod on f64 and f32/f16 conversions, integer clamp on unsigned/packed adds and dots #118

Closed
gefydev wants to merge 1 commit from upstream-pr/119 into main
gefydev commented 2026-11-23 13:20:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-23T13:20:15Z.


#105 item 4.

Dropped before this change:

  • omod on the f64 VALU results (v_add_f64, v_mul_f64, v_fma_f64, …);
  • omod and clamp on v_cvt_f32_f64 and v_cvt_f16_f32;
  • integer clamp (saturation) on v_add_nc_u32, v_sub_nc_u32, v_subrev_nc_u32, v_add3_u32, v_pk_add/sub_u16, v_pk_add/sub_i16, v_pk_mad_u16/i16, v_dot2_{i32_i16,u32_u16}, v_dot4_{i32_i8,u32_u8} and v_dot8_{i32_i4,u32_u4}. These wrapped instead.

One point of the audit was wrong: f64 clamp did not narrow to float. DXIL has a double Saturate, and the test confirms clamp keeps double precision on main. So that part is not changed.

Notes:

  • v_cvt_f16_f32 applies the modifiers in f32 before the rounding. The f16 is the same except where it is denormal.
  • The integer dots saturate the 64-bit sum of the products and the accumulator.
  • New helper in the prelude: sat_u32, next to sat_i32. No -Gis (per #73).

Test gpu_clamp_and_omod_per_instruction: every changed instruction once, with values that saturate. The non-clamp forms of an add, a packed add and a dot are controls that must still wrap. Without the emit change it fails (first at v_add_f64 omod). With it, it passes on a GTX 1650 under Wine (vkd3d-proton), and so do the other lib tests that run there. Not run on AMD.

<!-- greyfinch-sync:ivall/xcl:issue:6560242208 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/119). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-23T13:20:15Z. --- #105 item 4. Dropped before this change: - omod on the f64 VALU results (v_add_f64, v_mul_f64, v_fma_f64, …); - omod and clamp on `v_cvt_f32_f64` and `v_cvt_f16_f32`; - integer clamp (saturation) on `v_add_nc_u32`, `v_sub_nc_u32`, `v_subrev_nc_u32`, `v_add3_u32`, `v_pk_add/sub_u16`, `v_pk_add/sub_i16`, `v_pk_mad_u16/i16`, `v_dot2_{i32_i16,u32_u16}`, `v_dot4_{i32_i8,u32_u8}` and `v_dot8_{i32_i4,u32_u4}`. These wrapped instead. One point of the audit was wrong: f64 clamp did not narrow to float. DXIL has a double `Saturate`, and the test confirms clamp keeps double precision on main. So that part is not changed. Notes: - `v_cvt_f16_f32` applies the modifiers in f32 before the rounding. The f16 is the same except where it is denormal. - The integer dots saturate the 64-bit sum of the products and the accumulator. - New helper in the prelude: `sat_u32`, next to `sat_i32`. No `-Gis` (per #73). Test `gpu_clamp_and_omod_per_instruction`: every changed instruction once, with values that saturate. The non-clamp forms of an add, a packed add and a dot are controls that must still wrap. Without the emit change it fails (first at `v_add_f64` omod). With it, it passes on a GTX 1650 under Wine (vkd3d-proton), and so do the other lib tests that run there. Not run on AMD.
upstream-sync closed this pull request 2026-11-24 06:57:14 +00:00
ivall commented 2026-11-24 07:00:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T14:14:08Z.


Merged. It conflicted with fdeacf0, which made the plain v_dot4* SM 6.4 intrinsics (dot4add_i8packed / dot4add_u8packed, for FSR4). Your clamped forms keep dot4_u8 / dot4_i8 (c4df2fe): written with the intrinsic, (int64_t)dot4add_i8packed(a, b, 0) gave DXC an internal compiler error. Your test passes on the RX 9070. Checked on Windows 11 with an RX 9070 (RDNA4), merged together with the rest of #110–#129: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; the retail pack still translates 26 698 / 26 698; the FSR4 GPU probe passes; Unicorn Overlord and XDefiant run. Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7103687095 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/119#issuecomment-7103687095). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T14:14:08Z. --- Merged. It conflicted with fdeacf0, which made the plain `v_dot4*` SM 6.4 intrinsics (`dot4add_i8packed` / `dot4add_u8packed`, for FSR4). Your clamped forms keep `dot4_u8` / `dot4_i8` (c4df2fe): written with the intrinsic, `(int64_t)dot4add_i8packed(a, b, 0)` gave DXC an internal compiler error. Your test passes on the RX 9070. Checked on Windows 11 with an RX 9070 (RDNA4), merged together with the rest of #110–#129: `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with `XCL_SPLIT_WAVE64=1`; the retail pack still translates 26 698 / 26 698; the FSR4 GPU probe passes; Unicorn Overlord and XDefiant run. Thanks!
ivall commented 2026-11-24 07:00:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T14:15:06Z.


Closing by hand: your rebase (28caa63) landed while I merged the earlier head (34efd81, merge 73c7bbe on main), so GitHub doesn't see it as merged. The content is in. One difference: the rebase writes the clamped 8-bit dots as (int64_t)dot4add_i8packed(a, b, 0) / (uint64_t)dot4add_u8packed(a, b, 0u) - that exact form gave DXC (Windows SDK 10.0.26100) an internal compiler error in gpu_clamp_and_omod_per_instruction, so main keeps your dot4_i8 / dot4_u8 helpers there (c4df2fe).

<!-- greyfinch-sync:ivall/xcl:comment:7103711449 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/119#issuecomment-7103711449). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T14:15:06Z. --- Closing by hand: your rebase (28caa63) landed while I merged the earlier head (34efd81, merge 73c7bbe on `main`), so GitHub doesn't see it as merged. The content is in. One difference: the rebase writes the clamped 8-bit dots as `(int64_t)dot4add_i8packed(a, b, 0)` / `(uint64_t)dot4add_u8packed(a, b, 0u)` - that exact form gave DXC (Windows SDK 10.0.26100) an internal compiler error in `gpu_clamp_and_omod_per_instruction`, so `main` keeps your `dot4_i8` / `dot4_u8` helpers there (c4df2fe).

Pull request closed

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
xcl-dev/xcl!118
No description provided.