shader: lower v_frexp_exp_i32_f32 and v_frexp_mant_f32 in the direct compute path #3117

Manually merged
github merged 2 commits from github-bot/gh-3117 into gh-pr/3117/base 2026-11-27 18:08:00 +00:00 AGit
Owner

@⁠R0D4X on GitHub · 2026-11-27 15:59 UTC · original
R0D4X:feat/native-frexp-f32 → main · +220 −0 · 4 files · 2 commits · merged 2026-11-27 17:48 UTC

Fixes #3116. Refs #2935.

What this changes

  • Lowers v_frexp_exp_i32_f32 (VOP1 0x3f / VOP3A 0x1bf) and v_frexp_mant_f32 (VOP1 0x40 / VOP3A 0x1c0) in src/gfx1013_direct_compute.inl using exact 32-bit integer IEEE-754 binary32 manipulation.
  • Normalizes denormal inputs without flushing, preserves ±0.0, ±Inf, and NaN, supports VOP3A abs/neg on src0 and clamp on v_frexp_mant_f32, and refuses unsupported modifier combinations (clamp on v_frexp_exp_i32_f32, omod, op_sel, unused VOP3 sources).

Tests & docs added

  • tests/native_frexp_f32_check.py & tests/cmake/native_frexp_f32.cmake:
    • native_frexp_f32_controls: validates emitted integer DXIL (shl i32 / lshr i32), refuses invalid modifiers, and verifies that the flush_denormals and no_clamp negative controls differ.
    • native_frexp_f32_hardware: dispatches 8 binary32 edge cases (±0.0, normals, smallest normal, largest/smallest subnormals, +Inf) across VOP1 and VOP3A (neg, abs + clamp), matching 2048 result words and 16 sentinel guards.
  • docs/experiments/native-frexp-f32.md: experiment note and reproduction commands.

Verification

  • Commit: 2b5610a9
  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK / DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2124).
  • ctest --preset dev --no-tests=error -R '^native_frexp_f32_|^native_ldexp_' -V: 4/4 passed (0 skipped).
  • ctest --preset release --no-tests=error -R '^native_frexp_f32_|^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_exp_i32_f32 and v_frexp_mant_f32 only; does not establish full-game execution.

**@⁠R0D4X** on GitHub · 2026-11-27 15:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3117) `R0D4X:feat/native-frexp-f32` → `main` · +220 −0 · 4 files · 2 commits · merged 2026-11-27 17:48 UTC Fixes #3116. Refs #2935. ## What this changes - Lowers `v_frexp_exp_i32_f32` (VOP1 `0x3f` / VOP3A `0x1bf`) and `v_frexp_mant_f32` (VOP1 `0x40` / VOP3A `0x1c0`) in `src/gfx1013_direct_compute.inl` using exact 32-bit integer IEEE-754 binary32 manipulation. - Normalizes denormal inputs without flushing, preserves `±0.0`, `±Inf`, and `NaN`, supports VOP3A `abs`/`neg` on `src0` and `clamp` on `v_frexp_mant_f32`, and refuses unsupported modifier combinations (`clamp` on `v_frexp_exp_i32_f32`, `omod`, `op_sel`, unused VOP3 sources). ## Tests & docs added - `tests/native_frexp_f32_check.py` & `tests/cmake/native_frexp_f32.cmake`: - `native_frexp_f32_controls`: validates emitted integer DXIL (`shl i32` / `lshr i32`), refuses invalid modifiers, and verifies that the `flush_denormals` and `no_clamp` negative controls differ. - `native_frexp_f32_hardware`: dispatches 8 binary32 edge cases (`±0.0`, normals, smallest normal, largest/smallest subnormals, `+Inf`) across VOP1 and VOP3A (`neg`, `abs` + `clamp`), matching 2048 result words and 16 sentinel guards. - `docs/experiments/native-frexp-f32.md`: experiment note and reproduction commands. ## Verification - Commit: `2b5610a9` - Environment: Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230`, Windows SDK / DXC `10.0.26100.0`, NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2124`). - `ctest --preset dev --no-tests=error -R '^native_frexp_f32_|^native_ldexp_' -V`: **4/4 passed** (0 skipped). - `ctest --preset release --no-tests=error -R '^native_frexp_f32_|^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_exp_i32_f32` and `v_frexp_mant_f32` only; does not establish full-game execution.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 16:07:39 +00:00
github-bot changed target branch from main to gh-pr/3117/base 2026-11-27 18:07:58 +00:00
github manually merged commit 03f6210882 into gh-pr/3117/base 2026-11-27 18:08:00 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-27 17:47 UTC · original · reviewed

Review of 03f6210882 (the change from 2b5610a9, updated with main; the PR's own diff is unchanged).

Code: zero, Inf and NaN keep the input (mantissa op) or give 0 (exponent op). Normal inputs give sign | 0.5 | fraction and exponent - 126. Denormals are normalized with a five-step shift count, so the exponent becomes 1 - steps - 126 and the fraction is the normalized mantissa; I checked both formulas against frexp for a denormal with its top bit at position p (result exponent p - 148). abs/neg on src0 are applied before the split, clamp is refused on the exponent op and clamps the mantissa to [0, 1] (NaN and negative to 0), and omod, op_sel, DPP/SDWA and unused sources are refused. The test reference is computed independently, and the flushed-denormal and no-clamp controls change the expected words. 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/3117/head -- src/ tests/ (read), plus the Windows commands listed in the comment.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-27 17:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3117#pullrequestreview-6091721124) · **reviewed** Review of 03f621088220578ca36846b1e33fec433cc92192 (the change from 2b5610a9, updated with main; the PR's own diff is unchanged). Code: zero, Inf and NaN keep the input (mantissa op) or give 0 (exponent op). Normal inputs give sign | 0.5 | fraction and exponent - 126. Denormals are normalized with a five-step shift count, so the exponent becomes 1 - steps - 126 and the fraction is the normalized mantissa; I checked both formulas against frexp for a denormal with its top bit at position p (result exponent p - 148). abs/neg on src0 are applied before the split, clamp is refused on the exponent op and clamps the mantissa to [0, 1] (NaN and negative to 0), and omod, op_sel, DPP/SDWA and unused sources are refused. The test reference is computed independently, and the flushed-denormal and no-clamp controls change the expected words. 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/3117/head -- src/ tests/` (read), plus the Windows commands listed in the comment. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-27 17:47 UTC · original

Windows Server 2025 verification of 03f621088220578ca36846b1e33fec433cc92192 (D3D12 WARP, MSVC 14.44.35207):

  • dev: cmake --build --preset dev --target compile_dxil native_store_replay; ctest --preset dev -R <native sweep>: 100% tests passed out of 126 (73 passed, 53 hardware legs skipped)
  • release: cmake --build --preset release --target compile_dxil native_store_replay; ctest --preset release -R <native sweep>: 100% tests passed out of 126 (73 passed, 53 skipped)

<native sweep> = every native_* test except native_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_f32_controls passed in both presets; the _hardware leg skips on WARP because it needs a physical wave32 adapter.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-27 17:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3117#issuecomment-7224796826) Windows Server 2025 verification of `03f621088220578ca36846b1e33fec433cc92192` (D3D12 WARP, MSVC 14.44.35207): - dev: `cmake --build --preset dev --target compile_dxil native_store_replay`; `ctest --preset dev -R <native sweep>`: 100% tests passed out of 126 (73 passed, 53 hardware legs skipped) - release: `cmake --build --preset release --target compile_dxil native_store_replay`; `ctest --preset release -R <native sweep>`: 100% tests passed out of 126 (73 passed, 53 skipped) `<native sweep>` = every `native_*` test except `native_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_f32_controls` passed in both presets; the `_hardware` leg skips on WARP because it needs a physical wave32 adapter. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.