shader: lower gfx1013 v_cvt_f32_f16 in pixel_aot #297

Manually merged
github merged 1 commit from gh-pr/297/head into gh-pr/297/base 2026-11-26 21:41:04 +00:00
Owner

@⁠Its3rr0rsWRLD on GitHub · 2026-11-21 21:13 UTC · original
Its3rr0rsWRLD:shader/cvt-f32-f16 → main · +87 −0 · 3 files · 1 commits · merged 2026-11-21 21:56 UTC

Change

pixel_aot rejected v_cvt_f32_f16, which widens the binary16 in the low 16 bits of S0 to binary32. This adds a widen16 helper that builds the binary32 encoding from the half's sign, exponent and mantissa bits, so the result does not depend on how a desktop driver treats denormals: a subnormal half becomes m × 2^-24 exactly. abs and neg modifiers are applied after widening and clamp saturates the result. Integer inline constants and literals are taken as raw words; a floating-point inline constant and SDWA forms are refused. Independent problem: it widens the conversions the pixel translator accepts.

Overlap: #288, #292 and #293 also edit tools/pixel_aot.py, tests/pixel_aot_check.py and docs/experiments.md on separate lines. I merged all four branches onto d311159 in three different orders without conflicts; the controls and the binary check pass on the combination. None depends on another. #232 lowers other conversions (v_cvt_f32_ubyte0, integer conversions) and does not touch this instruction.

Verification

Commit d311159 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC.

ctest --preset dev --no-tests=error -R '^pixel_aot_' -V
  • pixel_aot_hardware: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.
  • pixel_aot_warp: Passed on WARP 10.0.26100.9818.
  • Every draw reports debug_errors=0 and max_absolute_error=0. Each test runs 41 draws with this change and 40 on d311159; the extra draw is the new one.
  • tests/pixel_aot_check.py binary passes with the program added to the binary fixtures: LLVM 15.0.6 llvm-mc and llvm-objcopy, disassembled through libLLVM-17.so and libLLVM-18.so on Linux (no shared LLVM 15 library was available). Unchanged main passes the same check with both libraries. The Ubuntu CI job runs it with LLVM 15.
  • tests/docs_links_check.py and tests/bidi_controls_check.py pass.

Evidence and follow-up

The fixture is synthetic. Four constant words: 0xdead3c00 (1.0 with junk in the high half), 0x0000c500 drawn as -|s45| (-5.0), 0x00007bff (65504, the largest finite half) and 0xbeef0001 (the smallest subnormal half, 2^-24, again with junk above it), which a multiply by the literal 2^24 turns into 1.0. Negative controls, one per channel, each must report pixel_mismatch and does: a reference built from the high half, one without the negation, one with a wrong exponent (32752) and one with the subnormal flushed (0). The controls also check that all four conversions go through widen16 with the modifier outside it, and refuse a floating-point inline constant and an SDWA high-half selection. The translator on d311159 rejects the program at its first v_cvt_f32_f16.

Not measured here: NaN and infinite halves, which are not drawn, and whether Scarlett quiets a signaling NaN when widening; the lowering keeps the payload. Recorded in docs/experiments.md.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above.

**@⁠Its3rr0rsWRLD** on GitHub · 2026-11-21 21:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/297) `Its3rr0rsWRLD:shader/cvt-f32-f16` → `main` · +87 −0 · 3 files · 1 commits · merged 2026-11-21 21:56 UTC ## Change `pixel_aot` rejected `v_cvt_f32_f16`, which widens the binary16 in the low 16 bits of S0 to binary32. This adds a `widen16` helper that builds the binary32 encoding from the half's sign, exponent and mantissa bits, so the result does not depend on how a desktop driver treats denormals: a subnormal half becomes m × 2^-24 exactly. `abs` and `neg` modifiers are applied after widening and `clamp` saturates the result. Integer inline constants and literals are taken as raw words; a floating-point inline constant and SDWA forms are refused. Independent problem: it widens the conversions the pixel translator accepts. Overlap: #288, #292 and #293 also edit `tools/pixel_aot.py`, `tests/pixel_aot_check.py` and `docs/experiments.md` on separate lines. I merged all four branches onto d311159 in three different orders without conflicts; the controls and the binary check pass on the combination. None depends on another. #232 lowers other conversions (`v_cvt_f32_ubyte0`, integer conversions) and does not touch this instruction. ## Verification Commit d311159 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC. ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_' -V ``` - `pixel_aot_hardware`: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088. - `pixel_aot_warp`: Passed on WARP 10.0.26100.9818. - Every draw reports `debug_errors=0` and `max_absolute_error=0`. Each test runs 41 draws with this change and 40 on d311159; the extra draw is the new one. - `tests/pixel_aot_check.py binary` passes with the program added to the binary fixtures: LLVM 15.0.6 `llvm-mc` and `llvm-objcopy`, disassembled through `libLLVM-17.so` and `libLLVM-18.so` on Linux (no shared LLVM 15 library was available). Unchanged main passes the same check with both libraries. The Ubuntu CI job runs it with LLVM 15. - `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. ## Evidence and follow-up The fixture is synthetic. Four constant words: `0xdead3c00` (1.0 with junk in the high half), `0x0000c500` drawn as `-|s45|` (-5.0), `0x00007bff` (65504, the largest finite half) and `0xbeef0001` (the smallest subnormal half, 2^-24, again with junk above it), which a multiply by the literal 2^24 turns into 1.0. Negative controls, one per channel, each must report `pixel_mismatch` and does: a reference built from the high half, one without the negation, one with a wrong exponent (32752) and one with the subnormal flushed (0). The controls also check that all four conversions go through `widen16` with the modifier outside it, and refuse a floating-point inline constant and an SDWA high-half selection. The translator on d311159 rejects the program at its first `v_cvt_f32_f16`. Not measured here: NaN and infinite halves, which are not drawn, and whether Scarlett quiets a signaling NaN when widening; the lowering keeps the payload. Recorded in `docs/experiments.md`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above.
Widen the binary16 in the low half of S0 from its encoding, so subnormal halves stay exact whatever the desktop denormal mode, and apply abs, neg and clamp after widening. The draw ignores junk in the high half and checks -|x|, the largest finite half and the smallest subnormal half, with one wrong reference per channel; the program joins the gfx1013 binary fixtures.

AI-assisted: yes (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:41:03 +00:00
github manually merged commit 41474a474f into gh-pr/297/base 2026-11-26 21:41:04 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-21 21:28 UTC · original

At c8b042e, the merge conflicts are in docs/experiments.md. Please retain the neighboring experiment results and the half-widening reproduction command in the shared document.

**@⁠R0Y00** on GitHub · 2026-11-21 21:28 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/297#issuecomment-7069499675) At `c8b042e`, the merge conflicts are in `docs/experiments.md`. Please retain the neighboring experiment results and the half-widening reproduction command in the shared document.
Author
Owner

@⁠Its3rr0rsWRLD on GitHub · 2026-11-21 21:42 UTC · original

Rebased onto b53bfb0 after #270 and #299. The only conflict was in docs/experiments.md: the v_ceil_f32 paragraph from #270 is kept before this one. Nothing else changed.

ctest --preset dev --no-tests=error -R '^pixel_aot_' -V

At 41474a4 (b53bfb0 plus this change), Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC:

  • pixel_aot_hardware: Passed, NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.
  • pixel_aot_warp: Passed, WARP 10.0.26100.9818.
  • 51 draws on each adapter against 50 on b53bfb0, every one debug_errors=0 and max_absolute_error=0.
  • tests/pixel_aot_check.py binary, the controls, docs_links_check.py and bidi_controls_check.py pass on Linux with LLVM 15.0.6 tools and libLLVM 17 and 18.

This branch merges cleanly with each of my other open pixel_aot pull requests.

**@⁠Its3rr0rsWRLD** on GitHub · 2026-11-21 21:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/297#issuecomment-7069657635) Rebased onto b53bfb0 after #270 and #299. The only conflict was in `docs/experiments.md`: the `v_ceil_f32` paragraph from #270 is kept before this one. Nothing else changed. ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_' -V ``` At 41474a4 (b53bfb0 plus this change), Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC: - `pixel_aot_hardware`: Passed, NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088. - `pixel_aot_warp`: Passed, WARP 10.0.26100.9818. - 51 draws on each adapter against 50 on b53bfb0, every one `debug_errors=0` and `max_absolute_error=0`. - `tests/pixel_aot_check.py binary`, the controls, `docs_links_check.py` and `bidi_controls_check.py` pass on Linux with LLVM 15.0.6 tools and libLLVM 17 and 18. This branch merges cleanly with each of my other open pixel_aot pull requests.
This discussion has been locked. Commenting is limited to contributors.
No description provided.