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

Closed
github-bot wants to merge 1 commit from gh-pr/119/head into gh-pr/119/base
Owner

@⁠gefydev on GitHub · 2026-11-23 13:20 UTC · original
gefydev:recomp-clamp-omod → main · +152 −6 · 2 files · 1 commits · closed without merging

#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.

**@⁠gefydev** on GitHub · 2026-11-23 13:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/119) `gefydev:recomp-clamp-omod` → `main` · +152 −6 · 2 files · 1 commits · closed without merging #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.
The f64 VALU path, v_cvt_f32_f64 and v_cvt_f16_f32 dropped omod (and the two
conversions dropped clamp too). Integer clamp (saturation) was handled only
on v_add_nc_i32 / v_sub_nc_i32; v_add_nc_u32, v_sub_nc_u32, v_subrev_nc_u32,
v_add3_u32, v_pk_{add,sub}_{u16,i16}, v_pk_mad_{u16,i16} and the integer
dot products wrapped instead.

f64 clamp already kept double precision (DXIL has a double saturate), so it
stays. v_cvt_f16_f32 applies the modifiers in f32 before rounding: the same
f16 except where it is denormal.

Test gpu_clamp_and_omod_per_instruction: every changed instruction, with
the non-clamp forms of an add, a packed add and a dot as a control.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:11:03 +00:00
github-bot closed this pull request 2026-11-26 04:11:03 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 14:14 UTC · original

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** on GitHub · 2026-11-23 14:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/119#issuecomment-7103687095) 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!
Author
Owner

@⁠ivall on GitHub · 2026-11-23 14:15 UTC · original

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).

**@⁠ivall** on GitHub · 2026-11-23 14:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/119#issuecomment-7103711449) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.