shader: map inline binary16 float constants in v_floor/ceil/trunc/rndne_f16 #3324

Manually merged
github merged 3 commits from github-bot/gh-3322 into gh-pr/3322/base 2026-11-28 11:27:56 +00:00 AGit
Owner

@⁠R0D4X on GitHub · 2026-11-28 09:32 UTC · original
R0D4X:fix/native-round-f16-inline → main · +85 −39 · 4 files · 3 commits · merged 2026-11-28 11:14 UTC

Fixes #3320. Refs #2935.

What this changes

  • Maps inline float constants (src0 in 240..248) through inline_half_words[r - 240] in the v_floor_f16, v_ceil_f16, v_trunc_f16, and v_rndne_f16 lowering in src/gfx1013_direct_compute.inl (matching v_frexp_mant_f16/v_frexp_exp_i16_f16), instead of truncating the f32 bit pattern.
  • Adds if (graphics_input) return false; to the binary16 rounding block and tightens tests/cmake/native_round_f16.cmake to TARGET compile_dxil AND TARGET native_store_replay.

Tests & docs updated

  • tests/native_round_f16_check.py: adds an inline-constant batch (0.5, -0.5, 1.0, -1.0, 2.0, -2.0, 4.0, 1/(2*pi) = 0x3118) across all four opcodes, DXIL constant checks (14336, 12568), and an inline_as_zero negative control.
  • docs/experiments/native-round-f16.md: documents inline binary16 float constant coverage.

Verification

  • Commit: 13059b79
  • 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.2140).
  • ctest --preset dev --no-tests=error -R '^native_round_f16_|^native_frexp_f16_' -V: 5/5 passed (0 skipped).
  • ctest --preset release --no-tests=error -R '^native_round_f16_|^native_frexp_f16_': 5/5 passed (0 skipped).
  • tests/docs_links_check.py & tests/bidi_controls_check.py: passed.

Scope: covers synthetic direct-DXIL compute fixtures for v_floor_f16, v_ceil_f16, v_trunc_f16, and v_rndne_f16 only; does not establish full-game execution.

**@⁠R0D4X** on GitHub · 2026-11-28 09:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3322) `R0D4X:fix/native-round-f16-inline` → `main` · +85 −39 · 4 files · 3 commits · merged 2026-11-28 11:14 UTC Fixes #3320. Refs #2935. ## What this changes - Maps inline float constants (`src0` in `240..248`) through `inline_half_words[r - 240]` in the `v_floor_f16`, `v_ceil_f16`, `v_trunc_f16`, and `v_rndne_f16` lowering in `src/gfx1013_direct_compute.inl` (matching `v_frexp_mant_f16`/`v_frexp_exp_i16_f16`), instead of truncating the f32 bit pattern. - Adds `if (graphics_input) return false;` to the binary16 rounding block and tightens `tests/cmake/native_round_f16.cmake` to `TARGET compile_dxil AND TARGET native_store_replay`. ## Tests & docs updated - `tests/native_round_f16_check.py`: adds an inline-constant batch (`0.5`, `-0.5`, `1.0`, `-1.0`, `2.0`, `-2.0`, `4.0`, `1/(2*pi)` = `0x3118`) across all four opcodes, DXIL constant checks (`14336`, `12568`), and an `inline_as_zero` negative control. - `docs/experiments/native-round-f16.md`: documents inline binary16 float constant coverage. ## Verification - Commit: `13059b79` - 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.2140`). - `ctest --preset dev --no-tests=error -R '^native_round_f16_|^native_frexp_f16_' -V`: **5/5 passed** (0 skipped). - `ctest --preset release --no-tests=error -R '^native_round_f16_|^native_frexp_f16_'`: **5/5 passed** (0 skipped). - `tests/docs_links_check.py` & `tests/bidi_controls_check.py`: **passed**. *Scope: covers synthetic direct-DXIL compute fixtures for `v_floor_f16`, `v_ceil_f16`, `v_trunc_f16`, and `v_rndne_f16` only; does not establish full-game execution.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 09:39:38 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-28 09:57 UTC · original

Is excluding graphics stages here intentional?

if (graphics_input) return false; removes the only direct DXIL lowering of v_floor_f16, v_ceil_f16, v_trunc_f16 and v_rndne_f16 (src/gfx1013_direct_compute.inl 1506 on main). The direct graphics path sets graphics_input (src/gfx1013_direct_graphics.inl 1309) and calls alu.arithmetic (1989), so vertex and pixel stages that lower these ops on main would get direct DXIL lowering for v_floor_f16 (line 4021).

v_frexp_*_f16, v_fract_f16 and v_cvt_norm_*_f16 have no such guard, and tests/native_fract_f16_check.py compiles v_fract_f16 through gfx1013-container-ps. If the exclusion is intended, please give the reason and say that graphics stages now refuse these ops, both in the PR text and in the experiment note, and add a graphics-stage refusal control.

**@⁠Leyukaka** on GitHub · 2026-11-28 09:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3322#issuecomment-7237577936) Is excluding graphics stages here intentional? `if (graphics_input) return false;` removes the only direct DXIL lowering of `v_floor_f16`, `v_ceil_f16`, `v_trunc_f16` and `v_rndne_f16` (`src/gfx1013_direct_compute.inl` 1506 on `main`). The direct graphics path sets `graphics_input` (`src/gfx1013_direct_graphics.inl` 1309) and calls `alu.arithmetic` (1989), so vertex and pixel stages that lower these ops on `main` would get `direct DXIL lowering for v_floor_f16` (line 4021). `v_frexp_*_f16`, `v_fract_f16` and `v_cvt_norm_*_f16` have no such guard, and `tests/native_fract_f16_check.py` compiles `v_fract_f16` through `gfx1013-container-ps`. If the exclusion is intended, please give the reason and say that graphics stages now refuse these ops, both in the PR text and in the experiment note, and add a graphics-stage refusal control.
Author
Owner

@⁠R0D4X on GitHub · 2026-11-28 10:02 UTC · original

Good catch @⁠Leyukaka — excluding graphics stages was unintentional. These four ops use pure integer bit manipulation with no FP16 mode dependence and already lower in direct graphics stages on main.

Removed if (graphics_input) return false; in f5cbd971 so this PR stays strictly scoped to mapping inline binary16 float constants 240..248 for both compute and graphics stages.

Re-verified on NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), Windows 11 (10.0.26300.9974), MSVC 19.44.35230, SDK DXC 10.0.26100.0:

  • ctest --preset dev --no-tests=error -R '^native_round_f16_' -V: 2/2 passed (0 skipped).
  • ctest --preset release --no-tests=error -R '^native_round_f16_' -V: 2/2 passed (0 skipped).
**@⁠R0D4X** on GitHub · 2026-11-28 10:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3322#issuecomment-7237629996) Good catch @⁠Leyukaka — excluding graphics stages was unintentional. These four ops use pure integer bit manipulation with no FP16 mode dependence and already lower in direct graphics stages on `main`. Removed `if (graphics_input) return false;` in `f5cbd971` so this PR stays strictly scoped to mapping inline binary16 float constants `240..248` for both compute and graphics stages. Re-verified on NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2140`), Windows 11 (`10.0.26300.9974`), MSVC `19.44.35230`, SDK DXC `10.0.26100.0`: - `ctest --preset dev --no-tests=error -R '^native_round_f16_' -V`: **2/2 passed** (0 skipped). - `ctest --preset release --no-tests=error -R '^native_round_f16_' -V`: **2/2 passed** (0 skipped).
github-bot changed target branch from main to gh-pr/3322/base 2026-11-28 11:27:53 +00:00
github manually merged commit 3df02e6578 into gh-pr/3322/base 2026-11-28 11:27:56 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 11:13 UTC · original · reviewed

Review of head 3df02e65 (the PR's own change is unchanged; the new head only merges current main).

What I checked:

  • src/gfx1013_direct_compute.inl: in the v_floor_f16 / v_ceil_f16 / v_trunc_f16 / v_rndne_f16 lowering, source operands 240..248 now read their binary16 pattern from inline_half_words[r - 240], the same table the neighbouring v_frexp_*_f16 lowering already uses. Before, the f32 bit pattern of the inline constant was truncated to 16 bits. Abs/neg modifiers are applied after the lookup, as before.
  • The 240..248 range matches the table size; other sources still use the masked operand.
  • Tests: native_round_f16_controls (the DXIL must contain the inline 0.5 and 1/(2*pi) f16 words) and native_round_f16_hardware (real D3D12 readback on WARP against a plain Python binary16 reference for the new inline-constant program as well as the main one; it ran and did not skip).
  • #3137 added the rounding lowering; no other open PR covers this slice.

Commands run:

  • Linux: git diff --check origin/main...HEAD clean, python3 -m py_compile tests/native_round_f16_check.py ok.
  • Windows Server 2025, D3D12 WARP 1.0.22, -R '^native_round_f16_(controls|hardware)$': dev 2/2 passed, release 2/2 passed.
  • Mutation 1 (the inline range starts at 241): native_round_f16_hardware fails at inline word 9 (got beef0000, expected beef3c00).
  • Mutation 2 (inline word sign flipped): both tests fail (DXIL check, and readback at inline word 8).

No blocking findings. The receipt follows in a separate comment.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 11:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3322#pullrequestreview-6097423943) · **reviewed** Review of head `3df02e65` (the PR's own change is unchanged; the new head only merges current `main`). What I checked: - `src/gfx1013_direct_compute.inl`: in the `v_floor_f16` / `v_ceil_f16` / `v_trunc_f16` / `v_rndne_f16` lowering, source operands 240..248 now read their binary16 pattern from `inline_half_words[r - 240]`, the same table the neighbouring `v_frexp_*_f16` lowering already uses. Before, the f32 bit pattern of the inline constant was truncated to 16 bits. Abs/neg modifiers are applied after the lookup, as before. - The 240..248 range matches the table size; other sources still use the masked operand. - Tests: `native_round_f16_controls` (the DXIL must contain the inline 0.5 and 1/(2*pi) f16 words) and `native_round_f16_hardware` (real D3D12 readback on WARP against a plain Python binary16 reference for the new inline-constant program as well as the main one; it ran and did not skip). - #3137 added the rounding lowering; no other open PR covers this slice. Commands run: - Linux: `git diff --check origin/main...HEAD` clean, `python3 -m py_compile tests/native_round_f16_check.py` ok. - Windows Server 2025, D3D12 WARP 1.0.22, `-R '^native_round_f16_(controls|hardware)$'`: dev 2/2 passed, release 2/2 passed. - Mutation 1 (the inline range starts at 241): `native_round_f16_hardware` fails at inline word 9 (got beef0000, expected beef3c00). - Mutation 2 (inline word sign flipped): both tests fail (DXIL check, and readback at inline word 8). No blocking findings. The receipt follows in a separate comment. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 11:13 UTC · original

Win2025 WARP receipt for head 3df02e65 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 3df02e65781142875f836fb03d6fc6050ddf6ee7:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target compile_dxil native_store_replay -- -j 6): 5.65s (configure 1.67s)
    • Test (ctest --preset dev -R '^native_round_f16_(controls|hardware)$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (0.75s: native_round_f16_controls 0.37s, native_round_f16_hardware 0.38s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target compile_dxil native_store_replay -- -j 6): 31.91s (configure 1.59s)
    • Test (ctest --preset release -R '^native_round_f16_(controls|hardware)$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (0.67s: native_round_f16_controls 0.30s, native_round_f16_hardware 0.30s)
  • sccache: 14/18 hits; wall 38.9s

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 11:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3322#issuecomment-7238414270) Win2025 WARP receipt for head 3df02e65 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `3df02e65781142875f836fb03d6fc6050ddf6ee7`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target compile_dxil native_store_replay -- -j 6`): `5.65s` (configure `1.67s`) - Test (`ctest --preset dev -R '^native_round_f16_(controls|hardware)$' --parallel 6 --no-tests=error --output-on-failure`): **2/2 passed** (`0.75s`: `native_round_f16_controls` `0.37s`, `native_round_f16_hardware` `0.38s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target compile_dxil native_store_replay -- -j 6`): `31.91s` (configure `1.59s`) - Test (`ctest --preset release -R '^native_round_f16_(controls|hardware)$' --parallel 6 --no-tests=error --output-on-failure`): **2/2 passed** (`0.67s`: `native_round_f16_controls` `0.30s`, `native_round_f16_hardware` `0.30s`) - `sccache`: 14/18 hits; wall `38.9s` AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.