Skip to content

GPU: round rectangle half-float attributes to even - #316

Open
avt0m4t48 wants to merge 1 commit into
fxceless:mainfrom
avt0m4t48:fix/rectangle-half-rounding
Open

avt0m4t48 wants to merge 1 commit into
fxceless:mainfrom
avt0m4t48:fix/rectangle-half-rounding

Conversation

@avt0m4t48

Copy link
Copy Markdown

Fixes #245.

The CPU rectangle fallback converts the generated fourth vertex's half-float attributes back to binary16. Round halfway values to the nearest even mantissa in both the normal and subnormal paths. Keep NaNs quiet and preserve their sign and the payload bits that fit in binary16.

Verification

  • Source-built R16_FLOAT rectangle tests reproduced both reports on 2119b0e. The midpoint above 1.0 rounded upward, and a quiet NaN became infinity. All six standalone primitive.rs tests passed with the patch.
  • An optimized differential against GCC _Float16 checked 353,946 binary32 inputs, including signed finite binary16 values, adjacent midpoints and their neighbors, and generated binary32 bit patterns. Numeric conversions matched. NaNs passed the separate quiet/sign checks.
  • rustfmt --check and git diff --check passed.

This verifies the CPU fallback. No native D3D12 or application run was performed.

Preserve NaN classification and representable payload bits when expanding an R16_FLOAT corner on the CPU. Use the same ties-to-even rounding in the normal and subnormal conversion paths.
@kaayzouee

Copy link
Copy Markdown

Duplicate of #315?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPU rectangle CPU fallback: FP16 conversion turns NaN into infinity and rounds ties up

2 participants