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

Open
avt0m4t48 wants to merge 1 commit from upstream-pr/316 into main
avt0m4t48 commented 2026-11-24 23:30:40 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-24T23:30:40Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593541588 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/316). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T23:30:40Z. --- 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.
kaayzouee commented 2026-11-25 01:12:06 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T00:59:08Z.


Duplicate of #315?

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149088967 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/316#issuecomment-7149088967). Originally posted by [kaayzouee](https://github.com/kaayzouee) on 2026-11-25T00:59:08Z. --- Duplicate of #315?
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/316:upstream-pr/316'
git switch 'upstream-pr/316'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/316'
git switch 'upstream-pr/316'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/316'
git switch 'upstream-pr/316'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/316'
git switch 'main'
git merge --squash 'upstream-pr/316'
git switch 'main'
git merge --ff-only 'upstream-pr/316'
git switch 'main'
git merge 'upstream-pr/316'
git push origin 'main'
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
fxceless/victory-fork!316
No description provided.