Repository navigation
Shaders: lower v_cvt_norm_i16_f16 and v_cvt_norm_u16_f16 - #376
Conversation
The f16 source (with abs/neg) is clamped to [-1, 1] or [0, 1], scaled by 32767 or 65535 and rounded to nearest even once from the exact product; NaN gives 0. The product is formed in integers from the f16's bits, because in f32 it has up to 26 significant bits and would round first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @LouisRiverstone for the exact-product conversion work. I tested head Result: 1 passed, 0 failed (69 filtered out). This exercises both signed and unsigned normalized f16 conversions against the test’s f64 reference over the synthetic edge-pattern set. It does not measure behavior on console hardware. |
|
RDNA2 hardware measurement over all 65,536 f16 patterns: the exact-product, round-to-nearest-even rule matches every one, in the FP16 mode that keeps input denormals. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) runs
AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run. |
Shaders: lower v_cvt_norm_i16_f16 and v_cvt_norm_u16_f16
Shaders: lower v_cvt_norm_i16_f16 and v_cvt_norm_u16_f16
v_cvt_norm_i16_f16andv_cvt_norm_u16_f16(VOP1 0x63/0x64) were not lowered, so any program using them failed to translate.write_half).flt16_to_snorm16/flt16_to_unorm16, the same rule as the f32pknormconversions. I haven't measured these two ops on console hardware.Test:
v_cvt_norm_i16_and_u16_f16_round_the_exact_productinvalu_tests.rsruns both ops on the host GPU and WARP. It covers 287 f16 patterns: every 251st pattern, plus ±0, subnormals, ±0.5 (the tie), the values next to 1, ±1, ±inf and NaNs. Each result is checked against an f64 reference.dxil.dll10.0.26100 passes.lower.rschange it fails withUnsupported { what: "v_cvt_norm_i16_f16" }.cargo test --workspace, clippy andcargo xtask policyare clean.No game files.
AI-assisted (Claude Code): I reviewed the change and ran the tests above.