ffx: define float-to-integer conversion at NaN and saturation boundaries #449

Manually merged
github merged 2 commits from gh-pr/449/head into gh-pr/449/base 2026-11-26 21:52:45 +00:00
Owner

@⁠descent81 on GitHub · 2026-11-22 04:06 UTC · original
descent81:ffx/defined-float-to-int → main · +132 −13 · 9 files · 2 commits · merged 2026-11-22 04:36 UTC

Fixes #439.

The dispatch translator used bare HLSL casts for both float-to-integer instructions. The new helpers convert NaN to zero and clamp the operand to a finite, representable value before the cast. Positive overflow selects the integer maximum explicitly, since that maximum is not exactly representable in binary32.

Verification

  • The LLVM 15 test assembles both instructions and checks the translated register values for 19 inputs, including signed zeros, NaNs, infinities and adjacent representable values at the integer boundaries.
  • A source-owned CTest checks the emitted ALU expressions and production HLSL helpers on WARP. All 19 pairs also matched on RTX 4060.
  • Rebuilt the four locally pinned FSR4 shaders. The D3D12 provider-loop replay matched all 256 final pixels per run on both backends, with zero debug errors or warnings.

The previous casts also matched in this D3D11 harness on these drivers. The change removes undefined cast inputs. Whether a normal dispatch supplies exceptional values remains unmeasured.

Reproduce after a dev build:

ctest --preset dev --no-tests=error -R '^ffx_float_to_int_warp$' -V
**@⁠descent81** on GitHub · 2026-11-22 04:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/449) `descent81:ffx/defined-float-to-int` → `main` · +132 −13 · 9 files · 2 commits · merged 2026-11-22 04:36 UTC Fixes #439. The dispatch translator used bare HLSL casts for both float-to-integer instructions. The new helpers convert NaN to zero and clamp the operand to a finite, representable value before the cast. Positive overflow selects the integer maximum explicitly, since that maximum is not exactly representable in binary32. ## Verification - The LLVM 15 test assembles both instructions and checks the translated register values for 19 inputs, including signed zeros, NaNs, infinities and adjacent representable values at the integer boundaries. - A source-owned CTest checks the emitted ALU expressions and production HLSL helpers on WARP. All 19 pairs also matched on RTX 4060. - Rebuilt the four locally pinned FSR4 shaders. The D3D12 provider-loop replay matched all 256 final pixels per run on both backends, with zero debug errors or warnings. The previous casts also matched in this D3D11 harness on these drivers. The change removes undefined cast inputs. Whether a normal dispatch supplies exceptional values remains unmeasured. Reproduce after a dev build: ```powershell ctest --preset dev --no-tests=error -R '^ffx_float_to_int_warp$' -V ```
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:52:43 +00:00
github manually merged commit ea6cb2f793 into gh-pr/449/base 2026-11-26 21:52:45 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 04:21 UTC · original

The 19 runtime pairs cover the agreed boundaries, but the old casts also pass this readback. The independent report in #439 found a distinguishing case: converting immediate +Inf and folding the result into a UAV store made DXC reject the old shader with “Assignment of undefined values to UAV.” Please add that immediate case through the FFX emitter to the Windows regression, verify the guarded shader compiles and reads back 0xffffffff / 0x7fffffff, and record the old-cast result with the compiler version. The existing runtime cases should stay.

**@⁠R0Y00** on GitHub · 2026-11-22 04:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/449#issuecomment-7074132277) The 19 runtime pairs cover the agreed boundaries, but the old casts also pass this readback. The independent report in #439 found a distinguishing case: converting immediate +Inf and folding the result into a UAV store made DXC reject the old shader with “Assignment of undefined values to UAV.” Please add that immediate case through the FFX emitter to the Windows regression, verify the guarded shader compiles and reads back 0xffffffff / 0x7fffffff, and record the old-cast result with the compiler version. The existing runtime cases should stay.
This discussion has been locked. Commenting is limited to contributors.
No description provided.