shader: define v_cvt_rpi/flr_i32_f32 for NaN, infinity and overflow in pixel_aot #1878

Merged
Asimmimx merged 1 commit from upstream-pr/1885 into main 2026-11-24 20:33:34 +00:00
Asimmimx commented 2026-11-24 20:07:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T20:07:06Z.


Change

Fixes #1772.

tools/pixel_aot.py now defines v_cvt_flr_i32_f32 and v_cvt_rpi_i32_f32 for every binary32 input, so runtime sources are no longer refused.

  • cvt_flr_i32_f32 / cvt_rpi_i32_f32 (the lazy HLSL helpers): a NaN gives 0x7fffffff when its sign bit is clear and 0x80000000 when it is set (quiet or signalling). Both infinities and out-of-range values saturate to 0x7fffffff / 0x80000000. The helpers replace the NaN word before any float operation, clamp the rounded value to [-2^31, 2^31 - 128] (2^31 - 1 is not a binary32) and select 0x7fffffff for x >= 2^31. No HLSL cast reads a NaN or an out-of-range value any more. Before this change, int(floor(x)) and int(f + ...) were undefined casts for those inputs. Finite in-range results are bit-identical to the old helpers, and rpi still computes the floor of the exact x + 0.5.
  • require_proven_i32_f32_range is removed. Its docstring said it refused unproven runtime inputs and NaN, infinite or out-of-range constants "until a native RDNA reference establishes exceptional behavior". It guarded nothing else, since it already accepted subnormal constants. Its two call sites are removed, and the comments that cited it (cvt_f64_f32_source_bits, the v_cvt_f64_f32 branch, the e64 branch) are updated. The other refusals are unchanged: clamp, omod, decimal or float literals, bare -0x..., reversed modifiers, DPP and SDWA, pending scalar or sample reads, and WQM.
  • tools/scan_unsupported_shaders.py: the e32 and e64 patterns for v_cvt_i32_f32 now also cover flr_i32 and rpi_i32. The scanner previously left both opcodes unsupported for the same reason.
  • docs/experiments.md: the flr/rpi paragraph is rewritten, and two stale "flr/rpi remain rejected" mentions in the neighbouring cvt paragraphs are removed.

This follows R0Y00's condition on #540: "Before extending to NaN, infinities, or out-of-range values, we need an independent native reference that can observe those results as raw words, including values around ±0.5 and both integer endpoints." #1772 cites two such references: Marvisak/VIctory#605 (comment) (gfx1036, HIP inline asm) and xcl-dev/xcl#639 (comment) (gfx1036 and RDNA 4 gfx1201, OpenCL inline asm). Both include ±0.5, 0.49999997, ±2^31, both infinities and NaNs of both signs. Below I add a third native readback, on gfx1032.

Caveat: gfx1032, gfx1036 and gfx1201 are desktop RDNA 2 and RDNA 4 parts, not gfx1013 or Scarlett.

Verification

Commit 122e2db2 (rebased on main df40e4bc). Windows 11 Pro 10.0.26300.9974, MSVC (VS dev shell via tools/dev.ps1), Windows SDK 10.0.26100.0, DXC 1.8.2502.11, Python from out/pe-env.

cmake --preset dev -DINTAKE_PYTHON=C:/Users/asimm/Desktop/Xbox2Windows/out/pe-env/Scripts/python.exe
cmake --build --preset dev --target offscreen_check -j 4
ctest --preset dev --no-tests=error -R '^pixel_aot_cvt_flr_rpi_(warp|hardware)$'
1/2 Test  #903: pixel_aot_cvt_flr_rpi_hardware ...   Passed   12.23 sec
2/2 Test #1072: pixel_aot_cvt_flr_rpi_warp .......   Passed    5.33 sec
100% tests passed, 0 tests failed out of 2
  • WARP: Microsoft Basic Render Driver (1414:008c), driver 10.0.26100.9818, D3D12 debug layer enabled, debug_errors=0 debug_warnings=0. Passed.
  • Hardware: AMD Radeon RX 6600 (1002:73ff, RDNA 2, gfx1032), driver 32.0.21045.29003, D3D12 debug layer enabled, debug_errors=0 debug_warnings=0. Passed.
  • Skips: none.

Python checks (out/pe-env/Scripts/python.exe -B), all passed:

  • tests/pixel_aot_check.py (no arguments: translator controls), exit 0
  • tests/rdna2_tools_check.py: OK (skipped=18). The skips are the existing LLVM-dependent cases.
  • tests/form_coverage_check.py: form coverage checks passed
  • tests/docs_links_check.py: Checked 18 Markdown files and 376 links.
  • tests/bidi_controls_check.py: Checked 1326 tracked source, script and build/CI files: no bidirectional controls.
  • tests/pso_readiness_check.py, tests/shader_census_check.py: passed

Not run: tests/pixel_aot_check.py binary. Only LLVM 19.1.1 (WinLibs) is installed here, and CI pins LLVM 15. This PR adds no binary round-trip fixtures; the existing ones are unchanged.

What the draw test now covers (check_cvt_flr_rpi_draw)

The existing finite rows, modifier rows and mutations are kept. They are added to:

  • Runtime exceptional rows. The inputs come from the constant buffer, so DXC cannot fold them. They run through e32 and e64, SGPR and VGPR. The 24 hand-worked rows are in CVT_FLR_RPI_EXCEPTIONAL: ±qNaN, ±sNaN, ±NaN with all payload bits, ±inf, ±2^31, ±(2^31 + 256), 2^31 - 128, ±2^63, ±FLT_MAX, 0.49999997, ±0.5, -0.50000006, ±(2^23 + 1) and 2^24 - 1. The Python references must reproduce the table before any draw.
  • Runtime e64 modifiers on NaN and infinity. |-qNaN|, -(+qNaN), -|+sNaN|, -(-NaN), |-inf|, -(+inf) and -|±(2^31+256)|, for both opcodes.
  • Literal constants. NaN, infinity and out-of-range values that DXC may fold at compile time.
  • Negative controls, each of which must report pixel_mismatch:
    • a case that expects 0 for NaN, which is what v_cvt_i32_f32 gives;
    • dropping abs or neg on a NaN source;
    • three mutants of the emitted helper: NaN sign select dropped, sign select reversed (0x80000000u - sign), and the 2^31 saturation select dropped.
  • Dev-time control, not committed: with the old cvt_flr_i32_f32 helper swapped in, the draw test fails on WARP (Expected ['pass', ...], got ['mismatch', ...]).

Evidence and follow-up

Native gfx1032 readback (RX 6600, dev-time probe, not committed). I ran v_cvt_flr_i32_f32 and v_cvt_rpi_i32_f32 as inline assembly in an OpenCL C kernel, loaded through ctypes. Device gfx1032, board AMD Radeon RX 6600, OpenCL driver 3652.0 (PAL,LC). Each input ran under all four MODE.IEEE / MODE.DX10_CLAMP settings, with f32 denormals flushed or kept, for eight modes. MODE was read back after each s_setreg and gave 0xc0, 0x2c0, 0x1c0, 0x3c0, 0xf0, 0x2f0, 0x1f0, 0x3f0. Every row of CVT_FLR_RPI_EXCEPTIONAL matched in all eight modes, including the rows the table marks "by rule": ±(2^31 + 256), 2^31 - 128, ±2^63 and ±FLT_MAX.

word        flr         rpi
0x7fc00000  0x7fffffff  0x7fffffff
0xffc00000  0x80000000  0x80000000
0x7f800001  0x7fffffff  0x7fffffff
0xff800001  0x80000000  0x80000000
0x7fffffff  0x7fffffff  0x7fffffff
0xffffffff  0x80000000  0x80000000
0x7f800000  0x7fffffff  0x7fffffff
0xff800000  0x80000000  0x80000000
0x4f000000  0x7fffffff  0x7fffffff
0xcf000000  0x80000000  0x80000000
0x4f000001  0x7fffffff  0x7fffffff
0xcf000001  0x80000000  0x80000000
0x4effffff  0x7fffff80  0x7fffff80
0x5f000000  0x7fffffff  0x7fffffff
0xdf000000  0x80000000  0x80000000
0x7f7fffff  0x7fffffff  0x7fffffff
0xff7fffff  0x80000000  0x80000000
0x3effffff  0x00000000  0x00000000
0x3f000000  0x00000000  0x00000001
0xbf000000  0xffffffff  0x00000000
0xbf000001  0xffffffff  0xffffffff
0x4b000001  0x00800001  0x00800001
0xcb000001  0xff7fffff  0xff7fffff
0x4b7fffff  0x00ffffff  0x00ffffff
0x80000001  mode-dependent: flr 0xffffffff with f32 denormals kept, 0x00000000 flushed; rpi 0
0x807fffff  mode-dependent: flr 0xffffffff with f32 denormals kept, 0x00000000 flushed; rpi 0
  • Denormals. Only negative subnormals through flr depend on MODE, which matches the gfx1036 report. The draws keep the harness's existing assumption, F32_DENORM_MODE = "preserve"; this PR does not change it. The console's FLOAT_MODE is not measured.
  • Old helpers on D3D12 (dev-time probe, not committed). The same 26 inputs went through D3D12 draws from the constant buffer with the pre-change helpers. WARP and the RX 6600 agreed with each other: every NaN gave 0x00000000 from both opcodes, and infinities and out-of-range values saturated. So the old undefined casts were not adapter-divergent on these two adapters. They gave 0 for NaN, which differs from the native 0x7fffffff / 0x80000000 in 6 of 26 rows per opcode. With the new helpers, 0 of 26 rows differ on both adapters.
  • Fixtures. All are synthetic gfx1013 assembly written in tests/pixel_aot_check.py, with hand-worked expected words. No game data.
  • Overlap with open PRs. I checked with git merge-tree against the open pixel_aot PRs #1790, #1680, #1670, #1644, #1638, #1612, #1584, #1572, #1568, #1466, #713, #532, #531 and #528.
    • #1790, #1584, #1572 and #1568 merge cleanly.
    • The others already conflict with current main in the same files, with the same number of conflict regions with or without this commit.
    • Only #528 (v_cvt_pkrtz_f16_f32) has one of this PR's changed lines inside an existing conflict region: the cvt e32/e64 branches in lower() and scanner lines 170-171.

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 (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6590399401 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1885). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T20:07:06Z. --- ## Change Fixes #1772. `tools/pixel_aot.py` now defines `v_cvt_flr_i32_f32` and `v_cvt_rpi_i32_f32` for every binary32 input, so runtime sources are no longer refused. - `cvt_flr_i32_f32` / `cvt_rpi_i32_f32` (the lazy HLSL helpers): a NaN gives `0x7fffffff` when its sign bit is clear and `0x80000000` when it is set (quiet or signalling). Both infinities and out-of-range values saturate to `0x7fffffff` / `0x80000000`. The helpers replace the NaN word before any float operation, clamp the rounded value to `[-2^31, 2^31 - 128]` (2^31 - 1 is not a binary32) and select `0x7fffffff` for `x >= 2^31`. No HLSL cast reads a NaN or an out-of-range value any more. Before this change, `int(floor(x))` and `int(f + ...)` were undefined casts for those inputs. Finite in-range results are bit-identical to the old helpers, and `rpi` still computes the floor of the exact `x + 0.5`. - `require_proven_i32_f32_range` is removed. Its docstring said it refused unproven runtime inputs and NaN, infinite or out-of-range constants "until a native RDNA reference establishes exceptional behavior". It guarded nothing else, since it already accepted subnormal constants. Its two call sites are removed, and the comments that cited it (`cvt_f64_f32_source_bits`, the `v_cvt_f64_f32` branch, the e64 branch) are updated. The other refusals are unchanged: clamp, omod, decimal or float literals, bare `-0x...`, reversed modifiers, DPP and SDWA, pending scalar or sample reads, and WQM. - `tools/scan_unsupported_shaders.py`: the e32 and e64 patterns for `v_cvt_i32_f32` now also cover `flr_i32` and `rpi_i32`. The scanner previously left both opcodes unsupported for the same reason. - `docs/experiments.md`: the flr/rpi paragraph is rewritten, and two stale "flr/rpi remain rejected" mentions in the neighbouring cvt paragraphs are removed. This follows R0Y00's condition on #540: "Before extending to NaN, infinities, or out-of-range values, we need an independent native reference that can observe those results as raw words, including values around ±0.5 and both integer endpoints." #1772 cites two such references: [Marvisak/VIctory#605 (comment)](https://github.com/Marvisak/VIctory/pull/605#issuecomment-7123302580) (gfx1036, HIP inline asm) and [xcl-dev/xcl#639 (comment)](https://github.com/xcl-dev/xcl/pull/639#issuecomment-7127563021) (gfx1036 and RDNA 4 gfx1201, OpenCL inline asm). Both include ±0.5, 0.49999997, ±2^31, both infinities and NaNs of both signs. Below I add a third native readback, on gfx1032. **Caveat:** gfx1032, gfx1036 and gfx1201 are desktop RDNA 2 and RDNA 4 parts, not gfx1013 or Scarlett. ## Verification Commit `122e2db2` (rebased on `main` `df40e4bc`). Windows 11 Pro 10.0.26300.9974, MSVC (VS dev shell via `tools/dev.ps1`), Windows SDK 10.0.26100.0, DXC 1.8.2502.11, Python from `out/pe-env`. ```powershell cmake --preset dev -DINTAKE_PYTHON=C:/Users/asimm/Desktop/Xbox2Windows/out/pe-env/Scripts/python.exe cmake --build --preset dev --target offscreen_check -j 4 ctest --preset dev --no-tests=error -R '^pixel_aot_cvt_flr_rpi_(warp|hardware)$' ``` ``` 1/2 Test #903: pixel_aot_cvt_flr_rpi_hardware ... Passed 12.23 sec 2/2 Test #1072: pixel_aot_cvt_flr_rpi_warp ....... Passed 5.33 sec 100% tests passed, 0 tests failed out of 2 ``` - **WARP:** Microsoft Basic Render Driver (`1414:008c`), driver 10.0.26100.9818, D3D12 debug layer enabled, `debug_errors=0 debug_warnings=0`. Passed. - **Hardware:** AMD Radeon RX 6600 (`1002:73ff`, RDNA 2, gfx1032), driver 32.0.21045.29003, D3D12 debug layer enabled, `debug_errors=0 debug_warnings=0`. Passed. - **Skips:** none. Python checks (`out/pe-env/Scripts/python.exe -B`), all passed: - `tests/pixel_aot_check.py` (no arguments: translator controls), exit 0 - `tests/rdna2_tools_check.py`: `OK (skipped=18)`. The skips are the existing LLVM-dependent cases. - `tests/form_coverage_check.py`: `form coverage checks passed` - `tests/docs_links_check.py`: `Checked 18 Markdown files and 376 links.` - `tests/bidi_controls_check.py`: `Checked 1326 tracked source, script and build/CI files: no bidirectional controls.` - `tests/pso_readiness_check.py`, `tests/shader_census_check.py`: passed **Not run:** `tests/pixel_aot_check.py binary`. Only LLVM 19.1.1 (WinLibs) is installed here, and CI pins LLVM 15. This PR adds no binary round-trip fixtures; the existing ones are unchanged. ### What the draw test now covers (`check_cvt_flr_rpi_draw`) The existing finite rows, modifier rows and mutations are kept. They are added to: - **Runtime exceptional rows.** The inputs come from the constant buffer, so DXC cannot fold them. They run through e32 and e64, SGPR and VGPR. The 24 hand-worked rows are in `CVT_FLR_RPI_EXCEPTIONAL`: `±qNaN`, `±sNaN`, `±NaN` with all payload bits, `±inf`, `±2^31`, `±(2^31 + 256)`, `2^31 - 128`, `±2^63`, `±FLT_MAX`, `0.49999997`, `±0.5`, `-0.50000006`, `±(2^23 + 1)` and `2^24 - 1`. The Python references must reproduce the table before any draw. - **Runtime e64 modifiers on NaN and infinity.** `|-qNaN|`, `-(+qNaN)`, `-|+sNaN|`, `-(-NaN)`, `|-inf|`, `-(+inf)` and `-|±(2^31+256)|`, for both opcodes. - **Literal constants.** NaN, infinity and out-of-range values that DXC may fold at compile time. - **Negative controls, each of which must report `pixel_mismatch`:** - a case that expects `0` for NaN, which is what `v_cvt_i32_f32` gives; - dropping `abs` or `neg` on a NaN source; - three mutants of the emitted helper: NaN sign select dropped, sign select reversed (`0x80000000u - sign`), and the `2^31` saturation select dropped. - **Dev-time control, not committed:** with the old `cvt_flr_i32_f32` helper swapped in, the draw test fails on WARP (`Expected ['pass', ...], got ['mismatch', ...]`). ## Evidence and follow-up **Native gfx1032 readback (RX 6600, dev-time probe, not committed).** I ran `v_cvt_flr_i32_f32` and `v_cvt_rpi_i32_f32` as inline assembly in an OpenCL C kernel, loaded through ctypes. Device `gfx1032`, board `AMD Radeon RX 6600`, OpenCL driver `3652.0 (PAL,LC)`. Each input ran under all four MODE.IEEE / MODE.DX10_CLAMP settings, with f32 denormals flushed or kept, for eight modes. MODE was read back after each `s_setreg` and gave `0xc0, 0x2c0, 0x1c0, 0x3c0, 0xf0, 0x2f0, 0x1f0, 0x3f0`. Every row of `CVT_FLR_RPI_EXCEPTIONAL` matched in all eight modes, including the rows the table marks "by rule": `±(2^31 + 256)`, `2^31 - 128`, `±2^63` and `±FLT_MAX`. ``` word flr rpi 0x7fc00000 0x7fffffff 0x7fffffff 0xffc00000 0x80000000 0x80000000 0x7f800001 0x7fffffff 0x7fffffff 0xff800001 0x80000000 0x80000000 0x7fffffff 0x7fffffff 0x7fffffff 0xffffffff 0x80000000 0x80000000 0x7f800000 0x7fffffff 0x7fffffff 0xff800000 0x80000000 0x80000000 0x4f000000 0x7fffffff 0x7fffffff 0xcf000000 0x80000000 0x80000000 0x4f000001 0x7fffffff 0x7fffffff 0xcf000001 0x80000000 0x80000000 0x4effffff 0x7fffff80 0x7fffff80 0x5f000000 0x7fffffff 0x7fffffff 0xdf000000 0x80000000 0x80000000 0x7f7fffff 0x7fffffff 0x7fffffff 0xff7fffff 0x80000000 0x80000000 0x3effffff 0x00000000 0x00000000 0x3f000000 0x00000000 0x00000001 0xbf000000 0xffffffff 0x00000000 0xbf000001 0xffffffff 0xffffffff 0x4b000001 0x00800001 0x00800001 0xcb000001 0xff7fffff 0xff7fffff 0x4b7fffff 0x00ffffff 0x00ffffff 0x80000001 mode-dependent: flr 0xffffffff with f32 denormals kept, 0x00000000 flushed; rpi 0 0x807fffff mode-dependent: flr 0xffffffff with f32 denormals kept, 0x00000000 flushed; rpi 0 ``` - **Denormals.** Only negative subnormals through `flr` depend on MODE, which matches the gfx1036 report. The draws keep the harness's existing assumption, `F32_DENORM_MODE = "preserve"`; this PR does not change it. The console's FLOAT_MODE is not measured. - **Old helpers on D3D12 (dev-time probe, not committed).** The same 26 inputs went through D3D12 draws from the constant buffer with the pre-change helpers. WARP and the RX 6600 agreed with each other: every NaN gave `0x00000000` from both opcodes, and infinities and out-of-range values saturated. So the old undefined casts were not adapter-divergent on these two adapters. They gave 0 for NaN, which differs from the native `0x7fffffff` / `0x80000000` in 6 of 26 rows per opcode. With the new helpers, 0 of 26 rows differ on both adapters. - **Fixtures.** All are synthetic gfx1013 assembly written in `tests/pixel_aot_check.py`, with hand-worked expected words. No game data. - **Overlap with open PRs.** I checked with `git merge-tree` against the open pixel_aot PRs #1790, #1680, #1670, #1644, #1638, #1612, #1584, #1572, #1568, #1466, #713, #532, #531 and #528. - #1790, #1584, #1572 and #1568 merge cleanly. - The others already conflict with current `main` in the same files, with the same number of conflict regions with or without this commit. - Only #528 (`v_cvt_pkrtz_f16_f32`) has one of this PR's changed lines inside an existing conflict region: the cvt e32/e64 branches in `lower()` and scanner lines 170-171. ## 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 (Claude Code).
upstream-sync closed this pull request 2026-11-24 21:01:07 +00:00
tedin7 commented 2026-11-24 21:01:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:24:04Z.

Review: COMMENTED


Peer review of head 122e2db27708d4374a133ce12a98cffd8240dd48 (PRODUCTION_REVIEW_ONLY, technical comment only).

No P1 and no P2 found in the lowering or in its tests. One open question for the maintainers about the evidence the new behavior rests on (below).

What the change does: v_cvt_flr_i32_f32 and v_cvt_rpi_i32_f32 (e32 and e64 with abs/neg) stop requiring a statically proven input. The two helpers now define NaN, infinities and out-of-range inputs, and tools/scan_unsupported_shaders.py accepts the same spellings. I read all five changed files.

Helper review (cvt_flr_i32_f32, cvt_rpi_i32_f32 in tools/pixel_aot.py):

  • The NaN test is on the raw word ((bits & 0x7fffffff) > 0x7f800000) and the NaN is replaced by 0 before any float operation. A NaN returns 0x7fffffff + (bits >> 31): 0x7fffffff with the sign clear, 0x80000000 with it set, quiet or signalling.
  • The rounded value is clamped to [-2^31, 2147483520] (the largest binary32 below 2^31), and x >= 2^31 selects 0x7fffffff before the cast, so no HLSL cast sees a NaN or an out-of-range value. +inf and -inf, +-2^31, +-FLT_MAX all land on the intended limits.
  • For rpi, an infinity gives x - floor(x) = NaN, the comparison is false, and the clamp and the >= 2^31 select still give the saturated values. For large integers (2^23 + 1) x - f is 0, so they are unchanged; 0x3effffff stays 0.
  • Finite in-range results are unchanged from the previous helpers.
  • Removal of require_proven_i32_f32_range and its two call sites leaves no dangling use (math and known_ssa_bits are still used elsewhere in the file).
  • The new tests, rdna2_tools_check entries and scanner entries are consistent with each other.

Question for the maintainers (not a defect in the code): the exceptional-input table (NaN by sign, saturation) comes from measurements on other RDNA parts, cited in issue #1772 (an RDNA 2 desktop APU and an RDNA 4 card) and in the docs (an RX 6600). The issue itself says none of these is gfx1013 or the console, and I cannot reproduce or inspect those measurements from here. Before this PR the two opcodes refused runtime inputs; after it, a title shader that feeds a NaN to them gets a defined result chosen from those measurements. If the console part differs, the failure would be silent. That is a project decision, so I am leaving it to you rather than judging it.

Mutations of the helpers in tools/pixel_aot.py, one at a time (each restored with git checkout -- .):

  • NaN sign select dropped (return nan ? 0x7fffffffu : word): tests/pixel_aot_check.py fails (rc=1) on Linux.
  • NaN not replaced before the float operations (asfloat(bits)): fails (rc=1) on Linux.
  • the x >= 2^31 saturation select dropped: the Linux check does not catch it (rc=0). On Windows Server 2025 with the mutated tree, pixel_aot_cvt_flr_rpi_warp fails ("case=3..7 and 12 mismatch", pixel_mismatch at 0,0), so the draw test pins it.
  • rpi half-way comparison changed from >= to >: passes the Linux check (rc=0). Only the WARP draw test covers values at exactly 0.5.

Commands run:

  • Linux: git diff --check <merge-base>...HEAD clean; tests/docs_links_check.py, tests/bidi_controls_check.py, tests/pixel_aot_check.py, tests/rdna2_tools_check.py (148 tests, 18 skipped), tests/form_coverage_check.py: all pass; the mutations above.
  • Windows Server 2025 (build 26100, MSVC 14.44, WARP) at the same commit 122e2db2, target offscreen_check, regex ^(pixel_aot_cvt_flr_rpi_warp|pixel_aot_warp|rdna2_tools_check)$:
    • Debug (--preset dev): 3/3 passed
    • Release /O2 (--preset release): 3/3 passed
    • Python checks tests/pixel_aot_check.py and tests/docs_links_check.py: ok
  • The merge against current main has no content conflicts (git merge-tree).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046782374 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1885#pullrequestreview-6046782374). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:24:04Z. **Review:** COMMENTED --- Peer review of head `122e2db27708d4374a133ce12a98cffd8240dd48` (PRODUCTION_REVIEW_ONLY, technical comment only). **No P1 and no P2 found in the lowering or in its tests. One open question for the maintainers about the evidence the new behavior rests on (below).** What the change does: `v_cvt_flr_i32_f32` and `v_cvt_rpi_i32_f32` (e32 and e64 with abs/neg) stop requiring a statically proven input. The two helpers now define NaN, infinities and out-of-range inputs, and `tools/scan_unsupported_shaders.py` accepts the same spellings. I read all five changed files. Helper review (`cvt_flr_i32_f32`, `cvt_rpi_i32_f32` in tools/pixel_aot.py): - The NaN test is on the raw word (`(bits & 0x7fffffff) > 0x7f800000`) and the NaN is replaced by 0 before any float operation. A NaN returns `0x7fffffff + (bits >> 31)`: `0x7fffffff` with the sign clear, `0x80000000` with it set, quiet or signalling. - The rounded value is clamped to [-2^31, 2147483520] (the largest binary32 below 2^31), and `x >= 2^31` selects `0x7fffffff` before the cast, so no HLSL cast sees a NaN or an out-of-range value. +inf and -inf, `+-2^31`, `+-FLT_MAX` all land on the intended limits. - For `rpi`, an infinity gives `x - floor(x) = NaN`, the comparison is false, and the clamp and the `>= 2^31` select still give the saturated values. For large integers (2^23 + 1) `x - f` is 0, so they are unchanged; `0x3effffff` stays 0. - Finite in-range results are unchanged from the previous helpers. - Removal of `require_proven_i32_f32_range` and its two call sites leaves no dangling use (`math` and `known_ssa_bits` are still used elsewhere in the file). - The new tests, `rdna2_tools_check` entries and scanner entries are consistent with each other. Question for the maintainers (not a defect in the code): the exceptional-input table (NaN by sign, saturation) comes from measurements on other RDNA parts, cited in issue #1772 (an RDNA 2 desktop APU and an RDNA 4 card) and in the docs (an RX 6600). The issue itself says none of these is gfx1013 or the console, and I cannot reproduce or inspect those measurements from here. Before this PR the two opcodes refused runtime inputs; after it, a title shader that feeds a NaN to them gets a defined result chosen from those measurements. If the console part differs, the failure would be silent. That is a project decision, so I am leaving it to you rather than judging it. Mutations of the helpers in tools/pixel_aot.py, one at a time (each restored with `git checkout -- .`): - NaN sign select dropped (`return nan ? 0x7fffffffu : word`): `tests/pixel_aot_check.py` fails (rc=1) on Linux. - NaN not replaced before the float operations (`asfloat(bits)`): fails (rc=1) on Linux. - the `x >= 2^31` saturation select dropped: the Linux check does not catch it (rc=0). On Windows Server 2025 with the mutated tree, `pixel_aot_cvt_flr_rpi_warp` fails ("case=3..7 and 12 mismatch", pixel_mismatch at 0,0), so the draw test pins it. - `rpi` half-way comparison changed from `>=` to `>`: passes the Linux check (rc=0). Only the WARP draw test covers values at exactly 0.5. Commands run: - Linux: `git diff --check <merge-base>...HEAD` clean; `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `tests/pixel_aot_check.py`, `tests/rdna2_tools_check.py` (148 tests, 18 skipped), `tests/form_coverage_check.py`: all pass; the mutations above. - Windows Server 2025 (build 26100, MSVC 14.44, WARP) at the same commit `122e2db2`, target `offscreen_check`, regex `^(pixel_aot_cvt_flr_rpi_warp|pixel_aot_warp|rdna2_tools_check)$`: - Debug (`--preset dev`): 3/3 passed - Release `/O2` (`--preset release`): 3/3 passed - Python checks `tests/pixel_aot_check.py` and `tests/docs_links_check.py`: ok - The merge against current `main` has no content conflicts (`git merge-tree`). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 21:01:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:30:07Z.

Review: COMMENTED


Peer review of head 122e2db27708d4374a133ce12a98cffd8240dd48 (TIER_D_ISOLATED_SHADER_OPS, technical comment).

No P1 and no P2 found. I read the diff of tools/pixel_aot.py, tools/scan_unsupported_shaders.py and the three test/doc files, and I agree with the earlier review on the helper logic (NaN word replaced before any float op, clamp to [-2^31, 2147483520], x >= 2^31 selects 0x7fffffff, finite in-range results unchanged, no dangling use of the removed function).

Note: the exceptional-input table comes from RDNA 2 (gfx1036) and RDNA 4 measurements cited in #1772, not from gfx1013 or the console. That is a project decision and I did not verify the hardware source.

Commands run locally:

  • git diff --check origin/main...HEAD: rc=0
  • python3 tests/docs_links_check.py: rc=0 (18 files, 376 links)
  • python3 tests/bidi_controls_check.py: rc=0
  • python3 tests/pixel_aot_check.py: rc=0
  • python3 tests/rdna2_tools_check.py: rc=0
  • Windows Server 2025 (build 26100, MSVC 14.44, WARP), target offscreen_check, regex ^(pixel_aot_cvt_flr_rpi_warp|pixel_aot_warp|rdna2_tools_check)$: Debug 3/3 passed, Release /O2 3/3 passed, tests/form_coverage_check.py ok

Mutations (each restored with git checkout -- .):

  • NaN sign select dropped in cvt_flr_i32_f32: pixel_aot_check.py rc=1 (caught by a source-text assertion, so this one is wording-level evidence only)
  • rpi half-way test >= changed to >: Linux check rc=0 (not caught on Linux)
  • x >= 2^31 saturation select dropped in cvt_flr_i32_f32: Linux check rc=0; on Windows Server 2025 with the mutated tree, pixel_aot_cvt_flr_rpi_warp fails rc=1 (draw status mismatch, e.g. expected 0x00000000 got 0x80000000), so the WARP draw test pins the saturation logic

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046876907 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1885#pullrequestreview-6046876907). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:30:07Z. **Review:** COMMENTED --- Peer review of head `122e2db27708d4374a133ce12a98cffd8240dd48` (TIER_D_ISOLATED_SHADER_OPS, technical comment). No P1 and no P2 found. I read the diff of `tools/pixel_aot.py`, `tools/scan_unsupported_shaders.py` and the three test/doc files, and I agree with the earlier review on the helper logic (NaN word replaced before any float op, clamp to [-2^31, 2147483520], `x >= 2^31` selects 0x7fffffff, finite in-range results unchanged, no dangling use of the removed function). Note: the exceptional-input table comes from RDNA 2 (gfx1036) and RDNA 4 measurements cited in #1772, not from gfx1013 or the console. That is a project decision and I did not verify the hardware source. Commands run locally: - `git diff --check origin/main...HEAD`: rc=0 - `python3 tests/docs_links_check.py`: rc=0 (18 files, 376 links) - `python3 tests/bidi_controls_check.py`: rc=0 - `python3 tests/pixel_aot_check.py`: rc=0 - `python3 tests/rdna2_tools_check.py`: rc=0 - Windows Server 2025 (build 26100, MSVC 14.44, WARP), target `offscreen_check`, regex `^(pixel_aot_cvt_flr_rpi_warp|pixel_aot_warp|rdna2_tools_check)$`: Debug 3/3 passed, Release /O2 3/3 passed, `tests/form_coverage_check.py` ok Mutations (each restored with `git checkout -- .`): - NaN sign select dropped in `cvt_flr_i32_f32`: `pixel_aot_check.py` rc=1 (caught by a source-text assertion, so this one is wording-level evidence only) - `rpi` half-way test `>=` changed to `>`: Linux check rc=0 (not caught on Linux) - `x >= 2^31` saturation select dropped in `cvt_flr_i32_f32`: Linux check rc=0; on Windows Server 2025 with the mutated tree, `pixel_aot_cvt_flr_rpi_warp` fails rc=1 (draw status mismatch, e.g. expected 0x00000000 got 0x80000000), so the WARP draw test pins the saturation logic AI-assisted; commands listed were executed locally.
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!1878
No description provided.