shader: lower gfx1013 v_cvt_f32_u32 and v_cvt_f32_i32 in pixel_aot #386

Merged
abilliontokens merged 5 commits from upstream-pr/392 into main 2026-11-22 10:27:54 +00:00
abilliontokens commented 2026-11-22 00:11:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T00:11:27Z.


Change

Refs #360 — stage 1 only (v_cvt_f32_u32_e32, v_cvt_f32_i32_e32), per the issue's proposed split; stages 2–3 stay with the proposer.

Depends on #363 (shader/pixel-fp-mode), which must land first: the discriminating rows (2^24 and above, 0xFFFFFFFF) cannot survive the compressed binary16 export, so the fixture uses #363's uncompressed f32 export and lossless readback. This branch is stacked on it.

  • lower() gains one anchored branch: v_cvt_f32_(u32|i32)_e32 vD, S → precise float alu = float(asuint(S)) / float(asint(S)), with the existing operand guards (entry mask, outstanding-sample overlap, pending constant loads, un-waited samples via fp_operand). The e64 spellings, abs/neg modifiers, clamp, omod, DPP and SDWA forms do not match and stay rejected.
  • Bit-exact sources: inputs are shader literals (v_mov_b32_e32 vN, 0x…), not constant-buffer words (#360 condition 3). v_mov_b32 emits asfloat(<word>u) — a pure bit-cast — so asuint/asint recover the exact 32 bits, including 0xFFFFFFFF and 0x80000000.
  • Rounding assumption recorded per the #312 convention: F32_ROUND_ASSUMPTION = "nearest-even" — CPU references convert via Python float then binary32 (RNE); the Scarlett pipeline MODE.FP_ROUND is unmeasured. If adapters disagree on a row, the result is recorded, not chosen.
  • Fixture check_cvt_int_f32_draw (both backends): five input pairs covering 0, 1, 2^24, 2^24+1 (tie→even), 2^25+1 (rounds down), 2^25+3 (rounds up), 2^25+2 (tie→even), 0x7FFFFFFF, 0xFFFFFFFF, 0x80000000; the reference asserts the tie rows round to even so the fixture discriminates rounding. Negative control: swapping u32↔i32 on (0xFFFFFFFF, 0x80000000) must report pixel_mismatch.
  • Rejection controls: e64, e64-abs/neg, clamp, omod, DPP, SDWA, and a pending-load SGPR source. The fixture joins check_binary's LLVM 15 round-trip list.
  • Coverage: docs/coverage/rdna2.tsv is regenerate-only (tools/form_reference.py); both VOP1 rows already exist and coverage derives from the ACCEPTED record at runtime, so no tsv edit. scan_unsupported_shaders.py is not maintained on this branch's convention (it already lacks several lowered forms); left untouched.

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 (the installer omits llvm-mc; assembly uses clang 15.0.7's integrated assembler — the same MC layer — through a local argv wrapper, disassembly uses 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

Result at this branch (rebased onto main at 4f6c39d; 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. the new one) passed
pixel_aot_hardware (default adapter, RTX 5060 Ti) Passed, 22.4 s
pixel_aot_warp (WARP 10.0.26100.9711) Passed, 4.3 s
pixel_aot_hardware with XBOX2WINDOWS_ADAPTER='RX 9060 XT' Passed, 16.5 s
pixel_aot_hardware with XBOX2WINDOWS_ADAPTER='RTX 5060 Ti' Passed, 22.1 s
tests/form_coverage_check.py passed

All draws report pixels=4096 channels=16384 max_absolute_error=0; the conversion rows match the nearest-even reference bit-for-bit on all three backends (no adapter disagreement to record); the swap negative control reports pixel_mismatch on every backend. Capability skips: none in this group. Until #363 merges, this PR's diff against main includes #363's commits; the incremental change is the single commit on top of them.

Evidence and follow-up

  • docs/experiments.md records the two instructions, the nearest-even assumption (console MODE.FP_ROUND unmeasured), the discriminating rows, the literal-input constraint and the swap negative control.
  • All existing fixtures are byte-identical; the change is purely additive.
  • No game files, dumps, distribution links or credentials; fixtures are source-built and synthetic.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6536183681 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/392). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:11:27Z. --- ## Change Refs #360 — **stage 1 only** (`v_cvt_f32_u32_e32`, `v_cvt_f32_i32_e32`), per the issue's proposed split; stages 2–3 stay with the proposer. **Depends on #363** (`shader/pixel-fp-mode`), which must land first: the discriminating rows (2^24 and above, `0xFFFFFFFF`) cannot survive the compressed binary16 export, so the fixture uses #363's uncompressed f32 export and lossless readback. This branch is stacked on it. - `lower()` gains one anchored branch: `v_cvt_f32_(u32|i32)_e32 vD, S` → `precise float alu = float(asuint(S))` / `float(asint(S))`, with the existing operand guards (entry mask, outstanding-sample overlap, pending constant loads, un-waited samples via `fp_operand`). The e64 spellings, `abs`/`neg` modifiers, `clamp`, `omod`, DPP and SDWA forms do not match and stay rejected. - Bit-exact sources: inputs are shader literals (`v_mov_b32_e32 vN, 0x…`), not constant-buffer words (#360 condition 3). `v_mov_b32` emits `asfloat(<word>u)` — a pure bit-cast — so `asuint`/`asint` recover the exact 32 bits, including `0xFFFFFFFF` and `0x80000000`. - Rounding assumption recorded per the #312 convention: `F32_ROUND_ASSUMPTION = "nearest-even"` — CPU references convert via Python float then binary32 (RNE); the Scarlett pipeline `MODE.FP_ROUND` is unmeasured. If adapters disagree on a row, the result is recorded, not chosen. - Fixture `check_cvt_int_f32_draw` (both backends): five input pairs covering 0, 1, 2^24, 2^24+1 (tie→even), 2^25+1 (rounds down), 2^25+3 (rounds up), 2^25+2 (tie→even), `0x7FFFFFFF`, `0xFFFFFFFF`, `0x80000000`; the reference asserts the tie rows round to even so the fixture discriminates rounding. Negative control: swapping u32↔i32 on (`0xFFFFFFFF`, `0x80000000`) must report `pixel_mismatch`. - Rejection controls: e64, e64-abs/neg, clamp, omod, DPP, SDWA, and a pending-load SGPR source. The fixture joins `check_binary`'s LLVM 15 round-trip list. - Coverage: `docs/coverage/rdna2.tsv` is regenerate-only (`tools/form_reference.py`); both VOP1 rows already exist and coverage derives from the ACCEPTED record at runtime, so no tsv edit. `scan_unsupported_shaders.py` is not maintained on this branch's convention (it already lacks several lowered forms); left untouched. ## 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 (the installer omits `llvm-mc`; assembly uses clang 15.0.7's integrated assembler — the same MC layer — through a local argv wrapper, disassembly uses `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 ``` Result at this branch (rebased onto `main` at `4f6c39d`; 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. the new one) | passed | | `pixel_aot_hardware` (default adapter, RTX 5060 Ti) | Passed, 22.4 s | | `pixel_aot_warp` (WARP 10.0.26100.9711) | Passed, 4.3 s | | `pixel_aot_hardware` with `XBOX2WINDOWS_ADAPTER='RX 9060 XT'` | Passed, 16.5 s | | `pixel_aot_hardware` with `XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'` | Passed, 22.1 s | | `tests/form_coverage_check.py` | passed | All draws report `pixels=4096 channels=16384 max_absolute_error=0`; the conversion rows match the nearest-even reference bit-for-bit on all three backends (no adapter disagreement to record); the swap negative control reports `pixel_mismatch` on every backend. Capability skips: none in this group. Until #363 merges, this PR's diff against `main` includes #363's commits; the incremental change is the single commit on top of them. ## Evidence and follow-up - `docs/experiments.md` records the two instructions, the nearest-even assumption (console `MODE.FP_ROUND` unmeasured), the discriminating rows, the literal-input constraint and the swap negative control. - All existing fixtures are byte-identical; the change is purely additive. - 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:48 +00:00
JB2WIN commented 2026-11-24 06:48:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T03:18:26Z.


Small gap noticed while doing stage 3 (#438): tools/scan_unsupported_shaders.py has no pattern for the stage-1 forms, so the scanner still reports v_cvt_f32_u32_e32 / v_cvt_f32_i32_e32 as unsupported after this PR. #438 adds the stage-3 pattern with the translator's literal spacing:

r"v_cvt_(?:u32|i32)_f32_e32 v\d+, (?:[vs]\d+|0x[0-9a-f]{1,8})",

The stage-1 equivalent would be r"v_cvt_f32_(?:u32|i32)_e32 v\d+, (?:[vs]\d+|0x[0-9a-f]{1,8}|-?\d+)" (matching the operand set of tools/pixel_aot.py's stage-1 regex), plus a case in TestRdna2Scanner (tests/rdna2_tools_check.py). I left it out of #438 because it belongs to this PR's scope. Happy to fold it into #438 instead if you prefer.

This comment is AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073453687 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/392#issuecomment-7073453687). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T03:18:26Z. --- Small gap noticed while doing stage 3 (#438): `tools/scan_unsupported_shaders.py` has no pattern for the stage-1 forms, so the scanner still reports `v_cvt_f32_u32_e32` / `v_cvt_f32_i32_e32` as unsupported after this PR. #438 adds the stage-3 pattern with the translator's literal spacing: ```python r"v_cvt_(?:u32|i32)_f32_e32 v\d+, (?:[vs]\d+|0x[0-9a-f]{1,8})", ``` The stage-1 equivalent would be `r"v_cvt_f32_(?:u32|i32)_e32 v\d+, (?:[vs]\d+|0x[0-9a-f]{1,8}|-?\d+)"` (matching the operand set of `tools/pixel_aot.py`'s stage-1 regex), plus a case in `TestRdna2Scanner` (`tests/rdna2_tools_check.py`). I left it out of #438 because it belongs to this PR's scope. Happy to fold it into #438 instead if you prefer. This comment is AI-assisted.
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!386
No description provided.