gpu(primitive): preserve NaN and use ties-to-even in FP16 rect expansion #337
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!337
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-337"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Caasares on GitHub · 2026-11-24 23:36 UTC · original
Caasares:fix/gpu-rect-fp16-nan-and-ties→main· +104 −4 · 1 files · 1 commits · openFixes #245
Summary
Fixes two IEEE-754 FP16 conversion bugs in the GPU rectangle list CPU fallback (
f32_to_halfincrates/victory-gpu/src/primitive.rs):exp >= 31caughtraw_exp == 0xffinputs indiscriminately, turningNaNvalues into±inf(sign | 0x7c00).(man + 0x1000) >> 13, which always rounds exact halfway ties up instead of rounding ties to even (unlike the subnormal branch).raw_exp == 0xffbefore normal/overflow handling: whenman != 0, return a sign-preserving quietNaNwith a guaranteed nonzero mantissa (sign | 0x7e00 | ((man >> 13) & 0x03ff)); whenman == 0, returnsign | 0x7c00.((man >> 13) & 1)((man + 0x0fff + ((man >> 13) & 1)) >> 13), preserving carry-out into the exponent and overflow tosign | 0x7c00.R16_FLOATexpand_rectsregression tests for both#245cases (normal even tie1.0, 0.0, 2^-11 -> 0x3c00and quietNaN0x7e00/0xfe00preservation) and verified they failed before the fix and pass after.f32_to_halfedge-case tests covering odd tie rounding up (1.0 + 2^-10 + 2^-11 -> 0x3c02), non-ties,±0.0,±inf, finite overflow to±inf, quiet/low-payloadNaNs, and subnormal round-to-even ties.Verification
rustfmt --edition 2024 --check crates/victory-gpu/src/primitive.rs— passedcargo clippy --workspace --all-targets --locked -- -D warnings— passed (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings— passed (0 warnings)cargo test --workspace --locked—499 passed; 0 failed; 7 ignoredacross the workspace (victory-gpu:113 passed; 0 failed; 1 ignored;xtaskincludingrepository_passes_policy:4 passed; 0 failed)Note: AI-assisted fix; contains no game files, keys, or assets.
@kaayzouee on GitHub · 2026-11-25 01:01 UTC · original
Duplicate of #315?
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.