gpu(primitive): preserve NaN and use ties-to-even in FP16 rect expansion #337
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from fxceless/victory-fork. Originally posted by Caasares on 2026-11-24T23:36:21Z.
Fixes #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.
Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T01:01:17Z.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.