Repository navigation
Conversation
|
Duplicate of #315? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.