pixel_aot: a native RDNA 2 reference for v_cvt_rpi/flr_i32_f32 exceptional inputs (NaN, ±inf, overflow) #1765

Closed
opened 2026-11-24 18:18:59 +00:00 by KainanP · 0 comments
KainanP commented 2026-11-24 18:18:59 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by KainanP on 2026-11-24T18:18:59Z.


tools/pixel_aot.py require_proven_i32_f32_range refuses unproven runtime inputs to v_cvt_rpi_i32_f32 / v_cvt_flr_i32_f32 "until a native RDNA reference establishes exceptional behavior". Here is one, so this can be decided:

  • Measured on RDNA 2 silicon (gfx1036) with inline assembly, identical in all four FLOAT_MODE (IEEE / DX10_CLAMP) settings: https://github.com/Marvisak/VIctory/pull/605#issuecomment-7123302580. Reproduced independently on gfx1036 and RDNA 4: https://github.com/xcl-dev/xcl/pull/639#issuecomment-7127563021
    • NaN: rpi and flr give 0x7FFFFFFF for a positive NaN and 0x80000000 for a negative one, quiet or signalling. v_cvt_i32_f32 / v_cvt_u32_f32 give 0.
    • Rounding: rpi is the floor of the exact x + 0.5, so 0.49999997 → 0. The cvt_rpi_i32_f32 helper in pixel_aot (f + ((x - f) >= 0.5f)) already matches this.
    • ±inf and out-of-range inputs saturate to the i32 limits (the remaining rows of that table).
  • In the helper, int(f + ...) / int(floor(x)) of a NaN or out-of-range value is an undefined HLSL cast. A sign-bit select for NaN plus a clamp would make the result defined. xcl-dev/xcl#1020 is a worked example.

Caveat: gfx1036 is a desktop RDNA 2 APU, not gfx1013 or Scarlett. This is the same kind of evidence #540 asked for, but not from the console itself.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588505032 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1772). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-24T18:18:59Z. --- `tools/pixel_aot.py` `require_proven_i32_f32_range` refuses unproven runtime inputs to `v_cvt_rpi_i32_f32` / `v_cvt_flr_i32_f32` "until a native RDNA reference establishes exceptional behavior". Here is one, so this can be decided: - Measured on RDNA 2 silicon (gfx1036) with inline assembly, identical in all four FLOAT_MODE (IEEE / DX10_CLAMP) settings: https://github.com/Marvisak/VIctory/pull/605#issuecomment-7123302580. Reproduced independently on gfx1036 and RDNA 4: https://github.com/xcl-dev/xcl/pull/639#issuecomment-7127563021 - NaN: `rpi` and `flr` give `0x7FFFFFFF` for a positive NaN and `0x80000000` for a negative one, quiet or signalling. `v_cvt_i32_f32` / `v_cvt_u32_f32` give 0. - Rounding: `rpi` is the floor of the exact x + 0.5, so 0.49999997 → 0. The `cvt_rpi_i32_f32` helper in `pixel_aot` (`f + ((x - f) >= 0.5f)`) already matches this. - ±inf and out-of-range inputs saturate to the i32 limits (the remaining rows of that table). - In the helper, `int(f + ...)` / `int(floor(x))` of a NaN or out-of-range value is an undefined HLSL cast. A sign-bit select for NaN plus a clamp would make the result defined. xcl-dev/xcl#1020 is a worked example. Caveat: gfx1036 is a desktop RDNA 2 APU, not gfx1013 or Scarlett. This is the same kind of evidence #540 asked for, but not from the console itself. _AI-assisted (Claude Code)._
Sign in to join this conversation.
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#1765
No description provided.