GPU: f32_to_half keeps NaN and rounds ties to even (fixes #843) #1069
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1069
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1069/head"
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?
@acleofe on GitHub · 2026-11-24 15:27 UTC · original
fix/gpu-f32-to-half-nan-even→main· +28 −3 · 1 files · 1 commits · closed without mergingWhat
f32_to_half(used for F16 elements when rectangle lists are expanded) converts NaN to a quiet half NaN, keeping the payload's top bits, and rounds normal values to nearest with ties to even:(man + 0xfff + ((man >> 13) & 1)) >> 13in place of(man + 0x1000) >> 13.Why
exp >= 31branch and came out as infinity.+ 0x1000rounds a value exactly halfway between two halves away from zero; IEEE 754 and the GPU round to the even one. The subnormal branch already rounded to even.Test
halves_keep_nan_and_round_ties_to_even: NaN, -NaN and the smallest NaN payload stay NaN; infinities stay;1 + 2^-11gives0x3c00,1 + 3·2^-11gives0x3c02, just past halfway rounds up. Fails before this change.cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsandcargo test --workspace --lockedpass.🤖 Generated with Claude Code
@Zipettte on GitHub · 2026-11-24 16:30 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
5f026f3:cargo test -p victory-gpupasses, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Pull request closed