shader: lower v_frexp_mant_f16 and v_frexp_exp_i16_f16 in the direct compute path #3120
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3120"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-27T16:04:32Z.
Fixes #3118. Refs #2935.
What this changes
v_frexp_mant_f16(VOP10x59/ VOP3A0x1d9) andv_frexp_exp_i16_f16(VOP10x5a/ VOP3A0x1da) insrc/gfx1013_direct_compute.inlusing exact 32-bit integer IEEE-754 binary16 manipulation while preservingD[31:16].±0.0h,±Inf, andNaN, supports VOP3Aabs/negonsrc0andclamponv_frexp_mant_f16, and refuses unsupported modifier combinations (clamponv_frexp_exp_i16_f16,omod,op_sel, unused VOP3 sources).Tests & docs added
tests/native_frexp_f16_check.py&tests/cmake/native_frexp_f16.cmake:native_frexp_f16_controls: validates emitted integer DXIL (shl i32/lshr i32), refuses invalid modifiers, and verifies that theflush_denormals,no_clamp, andzero_highnegative controls each differ.native_frexp_f16_hardware: dispatches 8 binary16 edge cases (±0.0h, normals, smallest normal, largest/smallest subnormals,+Inf) across VOP1 and VOP3A (neg,abs+clamp) with pre-seededD[31:16], matching 2048 result words and 16 sentinel guards.docs/experiments/native-frexp-f16.md: experiment note and reproduction commands.Verification
ebeb373d10.0.26300.9974), MSVC19.44.35230, Windows SDK / DXC10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver32.0.16.2124).ctest --preset dev --no-tests=error -R '^native_frexp_f16_|^native_ldexp_' -V: 4/4 passed (0 skipped).ctest --preset release --no-tests=error -R '^native_frexp_f16_|^native_ldexp_': 4/4 passed (0 skipped).tests/docs_links_check.py&tests/bidi_controls_check.py: passed.Scope: covers synthetic direct-DXIL compute fixtures for
v_frexp_mant_f16andv_frexp_exp_i16_f16only; does not establish full-game execution.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T17:48:29Z.
Review: COMMENTED
Review of
d6fdfce67e(the change fromebeb373d, updated with main; the PR's own diff is unchanged).Code: same structure as the f32 frexp lowering, on the low 16 bits of src0. Zero, Inf and NaN keep the input (mantissa op) or give 0 (exponent op); normal inputs give sign | 0.5h | fraction and exponent - 14; denormals are normalized with a four-step shift count, which gives exponent p - 23 for a denormal with its top bit at position p, as frexp expects. The result goes to D[15:0] and D[31:16] is kept, the same convention the other 16-bit results in this file use; the test seeds the high half of the destination and checks it survives. Clamp is refused on the exponent op and clamps the mantissa to [0, 1.0h]; omod, op_sel, DPP/SDWA and unused sources are refused. The reference is computed independently. No other open PR covers these two opcodes in the direct compute path.
Windows results are in the comment below.
Commands:
git diff origin/main...pull/3120/head -- src/ tests/(read), plus the Windows commands listed in the comment.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T17:48:31Z.
Windows Server 2025 verification of
d6fdfce67e940cba8b6e7900c11b3707d41949bd(D3D12 WARP, MSVC 14.44.35207):cmake --build --preset dev --target compile_dxil native_store_replay;ctest --preset dev -R <native sweep>: 100% tests passed out of 128 (74 passed, 54 hardware legs skipped)cmake --build --preset release --target compile_dxil native_store_replay;ctest --preset release -R <native sweep>: 100% tests passed out of 128 (74 passed, 54 skipped)<native sweep>= everynative_*test exceptnative_startup_request_cache_hardware, which fails on WARP-only hosts with or without this PR (wave lane count 32 requested, WARP offers 4; the test comes from #2955).native_frexp_f16_controlspassed in both presets; the_hardwareleg skips on WARP because it needs a physical wave32 adapter.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-27T19:39:21Z.
The private direct-compute intake found a concrete untested operand case at
429f11d5110: the f16 frexp lowering takesoperand32(src0) & 0xffff. Inline float sources 240-248 are f32 patterns inoperand32(e.g. 1.0 =0x3f800000, whose low half is zero), while the equivalent binary16 source is0x3c00. The frexp mantissa/exp for inline 1.0 should be 0.5h/1, not zero/0. Reuse the existing half operand decode convention and include inline 0.5, -1, 1 and 0.159 cases, plus signed NaN/negative-clamp reference controls. The f16 implementation also needs a proven half MODE/denorm contract or a typed refusal for unsupported FTZ/RTZ modes; graphics direct-path admission should remain unclaimed until measured. This is a static source finding, not new hardware evidence.