GPU: round FP16 rectangle corners to even and keep NaN (#245) #315

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

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


Fixes #245. In the CPU rectangle expansion, f32_to_half rounded exact ties up in the normal range and turned NaN into infinity. Ties now go to the even mantissa, as the subnormal path already does, and NaN becomes a quiet NaN with the same sign (the payload is not kept).

Tested (2119b0e + this change; GTX 1650 SUPER, Windows 11, Rust 1.98.1 gnullvm):

  • The new test goes through expand_rects and covers a tie rounding down, a tie rounding up, NaN and ±infinity. It fails without the fix; the NaN check also fails when only the NaN fix is removed.
  • cargo test --workspace --locked --no-fail-fast: 496 passed, 1 failed, 7 ignored. The failure is load_probe: building its fixture fails to link on gnullvm (/DELAYLOAD); this PR does not touch it.
  • Clippy (--all-targets -D warnings) passes, and rustfmt --check passes on the changed file.

Not tested: MSVC build, the all-features Clippy run, running a game.

AI use: written and tested with Claude Code.

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593537598 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/315). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T23:30:18Z. --- Fixes #245. In the CPU rectangle expansion, `f32_to_half` rounded exact ties up in the normal range and turned NaN into infinity. Ties now go to the even mantissa, as the subnormal path already does, and NaN becomes a quiet NaN with the same sign (the payload is not kept). **Tested** (2119b0e + this change; GTX 1650 SUPER, Windows 11, Rust 1.98.1 gnullvm): - The new test goes through `expand_rects` and covers a tie rounding down, a tie rounding up, NaN and ±infinity. It fails without the fix; the NaN check also fails when only the NaN fix is removed. - `cargo test --workspace --locked --no-fail-fast`: 496 passed, 1 failed, 7 ignored. The failure is `load_probe`: building its fixture fails to link on gnullvm (`/DELAYLOAD`); this PR does not touch it. - Clippy (`--all-targets -D warnings`) passes, and `rustfmt --check` passes on the changed file. **Not tested:** MSVC build, the all-features Clippy run, running a game. **AI use:** written and tested with Claude Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/315:upstream-pr/315'
git switch 'upstream-pr/315'

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/315'
git switch 'upstream-pr/315'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/315'
git switch 'upstream-pr/315'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/315'
git switch 'main'
git merge --squash 'upstream-pr/315'
git switch 'main'
git merge --ff-only 'upstream-pr/315'
git switch 'main'
git merge 'upstream-pr/315'
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!315
No description provided.