shader: lower gfx1013 v_cvt_f32_f16 in pixel_aot #293

Merged
Its3rr0rsWRLD merged 1 commit from upstream-pr/297 into main 2026-11-21 21:56:45 +00:00
Its3rr0rsWRLD commented 2026-11-21 21:13:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T21:13:32Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534467256 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/297). Originally posted by [Its3rr0rsWRLD](https://github.com/Its3rr0rsWRLD) on 2026-11-21T21:13:32Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 06:42:18 +00:00
R0Y00 commented 2026-11-24 06:48:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:28:32Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069499675 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/297#issuecomment-7069499675). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T21:28:32Z. --- 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.
Its3rr0rsWRLD commented 2026-11-24 06:48:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T21:42:01Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069657635 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/297#issuecomment-7069657635). Originally posted by [Its3rr0rsWRLD](https://github.com/Its3rr0rsWRLD) on 2026-11-21T21:42:01Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!293
No description provided.