shader: lower the e64 integer-to-f32 conversions with clamp in pixel_aot #411

Merged
abilliontokens merged 6 commits from upstream-pr/417 into main 2026-11-22 10:49:11 +00:00
abilliontokens commented 2026-11-22 01:02:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T01:02:56Z.


Change

Refs #360 — stage 2 (v_cvt_f32_u32_e64 / v_cvt_f32_i32_e64 with clamp), per the issue's proposed split. Stage 3 is claimed by @JB2WIN; stage 1 is #392.

Stacked on #392 (stage 1), which is stacked on #363; both must land first. Until then the diff against main includes their commits; the incremental change is the single commit on top.

  • lower() accepts the e64 forms with an optional clamp suffix, same operand guards as stage 1 (entry mask, outstanding-sample overlap, pending loads / un-waited samples via fp_operand); emission float(asuint/asint(src)), wrapped in saturate(...) under clamp. The e32 branch is unchanged and still rejects clamp.
  • omod is explicitly rejected, taking the issue's "or explicitly reject omod if it is out of scope" option, with a measured reason: LLVM 15.0.7's assembler rejects every probed omod syntax (omod:1/2/3, omod(2), mul:2, three-source spellings) on these forms and on v_add_f32_e64/v_mul_f32_e64, and a raw-encoding bit sweep (both dwords, 2-bit fields, values 1–3) never makes the disassembler print omod. omod cannot round-trip through the LLVM 15 text pipeline, so accepting it would be unverifiable. Rejection controls pin this.
  • abs/neg on the integer source stay rejected (the assembler itself refuses |s44| / -s44); DPP/SDWA variants stay rejected.
  • Fixture check_cvt_int_f32_e64_draw (both backends): e64 plain rows reuse the stage-1 discriminating words (e64 == e32 semantics, nearest-even reference); e64 clamp rows pair (0, 1), (2, 0xFFFFFFFF), (0x80000000, 0x7FFFFFFF) with Python-clamped references. Inputs remain v_mov_b32 literals.
  • Negative controls (fail on every backend): dropping clamp must mismatch on a row leaving [0,1] (u32 of 2 → 2.0 vs 1.0); swapping u32↔i32 under clamp on (0xFFFFFFFF, 0x80000000) must mismatch (1 vs 0).
  • The e64 plain and clamp programs join check_binary's LLVM 15 round-trip list. Rounding assumption unchanged: clamp rows are exact integers or exact clamps, so no new rounding ambiguity.

Verification

Environment: Windows 11 Pro build 26200.9711, MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Windows SDK 10.0.26100.0 (its DXC), CMake 4.4.3 / Ninja 1.13.2, Python 3.12.10. Adapters: AMD RX 9060 XT (32.0.32029.2010), NVIDIA RTX 5060 Ti (32.0.16.2124), in-box WARP 10.0.26100.9711. Debug layer unavailable (Graphics Tools not installed); runs report debug_layer=unavailable. LLVM 15.0.7 official win64 binaries (installer omits llvm-mc; assembly via clang 15.0.7's integrated assembler through a local argv wrapper, disassembly via LLVM-C.dll 15.0.7).

cmake --preset dev
cmake --build --preset dev
python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>
ctest --preset dev --no-tests=error -R '^pixel_aot_' --output-on-failure
$env:XBOX2WINDOWS_ADAPTER='RX 9060 XT'
ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
$env:XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'
ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
ctest --preset dev --no-tests=error --output-on-failure

Result at this branch (isolated worktree configured with the dev preset; ctest via --test-dir on that build, same filters):

Run Result
pixel_aot_check.py binary (LLVM 15.0.7 round trip, all fixtures incl. e64 plain and clamp) passed
pixel_aot_hardware (default adapter, RTX 5060 Ti) + pixel_aot_warp (WARP 10.0.26100.9711) passed
pixel_aot_hardware with XBOX2WINDOWS_ADAPTER='RX 9060 XT' passed
pixel_aot_hardware with XBOX2WINDOWS_ADAPTER='RTX 5060 Ti' passed
tests/form_coverage_check.py passed
Full suite ctest --no-tests=error 146/146 passed, 69.5 s

Capability skips reported separately: bvh_wave64_hardware (NVIDIA lanes 32..32), bvh_wave64_warp (WARP 4..4), wave_shuffle_warp (width-4 self-inverse). The e64 plain rows match the nearest-even reference and the clamp rows match the clamped reference bit-for-bit on all three backends (no adapter disagreement to record); both negative controls report pixel_mismatch on every backend.

Evidence and follow-up

  • docs/experiments.md records the e64/clamp forms, the measured LLVM 15 omod limitation, the clamp rows and both negative controls.
  • Stage-1 fixtures and all existing case files are byte-identical; the change is purely additive.
  • Stage 3 (v_cvt_u32_f32/v_cvt_i32_f32, e32) remains with @JB2WIN; the inverse instruction's e64 forms stay rejected in both patches.
  • No game files, dumps, distribution links or credentials; fixtures are source-built and synthetic.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6536609993 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/417). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T01:02:56Z. --- ## Change Refs #360 — **stage 2** (`v_cvt_f32_u32_e64` / `v_cvt_f32_i32_e64` with `clamp`), per the issue's proposed split. Stage 3 is claimed by @JB2WIN; stage 1 is #392. **Stacked on #392** (stage 1), which is stacked on #363; both must land first. Until then the diff against `main` includes their commits; the incremental change is the single commit on top. - `lower()` accepts the e64 forms with an optional `clamp` suffix, same operand guards as stage 1 (entry mask, outstanding-sample overlap, pending loads / un-waited samples via `fp_operand`); emission `float(asuint/asint(src))`, wrapped in `saturate(...)` under clamp. The e32 branch is unchanged and still rejects clamp. - **`omod` is explicitly rejected**, taking the issue's "or explicitly reject omod if it is out of scope" option, with a measured reason: LLVM 15.0.7's assembler rejects every probed omod syntax (`omod:1/2/3`, `omod(2)`, `mul:2`, three-source spellings) on these forms and on `v_add_f32_e64`/`v_mul_f32_e64`, and a raw-encoding bit sweep (both dwords, 2-bit fields, values 1–3) never makes the disassembler print `omod`. omod cannot round-trip through the LLVM 15 text pipeline, so accepting it would be unverifiable. Rejection controls pin this. - `abs`/`neg` on the integer source stay rejected (the assembler itself refuses `|s44|` / `-s44`); DPP/SDWA variants stay rejected. - Fixture `check_cvt_int_f32_e64_draw` (both backends): e64 plain rows reuse the stage-1 discriminating words (e64 == e32 semantics, nearest-even reference); e64 clamp rows pair (0, 1), (2, 0xFFFFFFFF), (0x80000000, 0x7FFFFFFF) with Python-clamped references. Inputs remain `v_mov_b32` literals. - Negative controls (fail on every backend): dropping clamp must mismatch on a row leaving [0,1] (u32 of 2 → 2.0 vs 1.0); swapping u32↔i32 under clamp on (0xFFFFFFFF, 0x80000000) must mismatch (1 vs 0). - The e64 plain and clamp programs join `check_binary`'s LLVM 15 round-trip list. Rounding assumption unchanged: clamp rows are exact integers or exact clamps, so no new rounding ambiguity. ## Verification Environment: Windows 11 Pro build 26200.9711, MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Windows SDK 10.0.26100.0 (its DXC), CMake 4.4.3 / Ninja 1.13.2, Python 3.12.10. Adapters: AMD RX 9060 XT (32.0.32029.2010), NVIDIA RTX 5060 Ti (32.0.16.2124), in-box WARP 10.0.26100.9711. Debug layer unavailable (Graphics Tools not installed); runs report `debug_layer=unavailable`. LLVM 15.0.7 official win64 binaries (installer omits `llvm-mc`; assembly via clang 15.0.7's integrated assembler through a local argv wrapper, disassembly via `LLVM-C.dll` 15.0.7). ```powershell cmake --preset dev cmake --build --preset dev python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll> ctest --preset dev --no-tests=error -R '^pixel_aot_' --output-on-failure $env:XBOX2WINDOWS_ADAPTER='RX 9060 XT' ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure $env:XBOX2WINDOWS_ADAPTER='RTX 5060 Ti' ctest --preset dev --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py ctest --preset dev --no-tests=error --output-on-failure ``` Result at this branch (isolated worktree configured with the `dev` preset; ctest via `--test-dir` on that build, same filters): | Run | Result | |---|---| | `pixel_aot_check.py binary` (LLVM 15.0.7 round trip, all fixtures incl. e64 plain and clamp) | passed | | `pixel_aot_hardware` (default adapter, RTX 5060 Ti) + `pixel_aot_warp` (WARP 10.0.26100.9711) | passed | | `pixel_aot_hardware` with `XBOX2WINDOWS_ADAPTER='RX 9060 XT'` | passed | | `pixel_aot_hardware` with `XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'` | passed | | `tests/form_coverage_check.py` | passed | | Full suite `ctest --no-tests=error` | **146/146 passed**, 69.5 s | Capability skips reported separately: `bvh_wave64_hardware` (NVIDIA lanes 32..32), `bvh_wave64_warp` (WARP 4..4), `wave_shuffle_warp` (width-4 self-inverse). The e64 plain rows match the nearest-even reference and the clamp rows match the clamped reference bit-for-bit on all three backends (no adapter disagreement to record); both negative controls report `pixel_mismatch` on every backend. ## Evidence and follow-up - `docs/experiments.md` records the e64/clamp forms, the measured LLVM 15 omod limitation, the clamp rows and both negative controls. - Stage-1 fixtures and all existing case files are byte-identical; the change is purely additive. - Stage 3 (`v_cvt_u32_f32`/`v_cvt_i32_f32`, e32) remains with @JB2WIN; the inverse instruction's e64 forms stay rejected in both patches. - No game files, dumps, distribution links or credentials; fixtures are source-built and synthetic. _AI-assisted._
upstream-sync closed this pull request 2026-11-24 06:42:56 +00:00
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!411
No description provided.