GPU: write half subnormals from f32 rectangle outputs #418
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/418"
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 Marvisak/VIctory. Originally posted by enzoduarte1 on 2026-11-24T03:10:15Z.
What
f32_to_halfreturned signed zero for everyexp <= 0, whilehalf_to_f32does decode half subnormals. An f16 rectangle output with a small value (for example2^-24, which is exactly0x0001) was therefore written as zero.The conversion now rounds the f32 significand into the half subnormal field for exponents down to
-10, with ties going to an even mantissa. Values below half the smallest subnormal still become zero, and normal values are untouched. A test covers both conversion directions, the largest subnormal, the tie cases, and sign.This is separate from PR #260, which fixes the rounding carry at the other end of the normal path.
Tested
x86_64-pc-windows-gnu(no MSVC linker on this machine).cargo test -p victory-gpu --lib primitive::: 3 passed.cargo test --workspace --exclude victory-loader -- --test-threads=1: all suites passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean here; on a full rebuild the pre-existinghost.rswarning fixed by PR #355 also appears.rustfmt --edition 2024 --check crates/victory-gpu/src/primitive.rsandgit diff --check: clean.cargo xtask policy: 151 files ok. No game files or data taken from them were added.cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's/DELAYLOADflag, which MinGW rejects here; the same failure occurs on unmodifiedmain.Checklist
cargo fmt,cargo clippy --workspace --all-targetsandcargo test --workspacepass — see the toolchain limitations above; the changed crate is clean.cargo xtask policypasses. The change adds no game files or data taken from them (docs/asset-policy.md).Imported from Marvisak/VIctory. Originally posted by towiice on 2026-11-24T03:21:28Z.
Review: COMMENTED
Tested PR head
eb30a0don Windows 11 x64 build 10.0.26300 (26H2), NVIDIA GeForce GTX 1650 SUPER (driver 610.88), Rust 1.100.0 (stable-x86_64-pc-windows-gnullvm):cargo test -p victory-gpu -- --test-threads=4: 44 passed, 0 failed, 1 ignored (0.57 s).All
victory-gputests (including the new f32-to-half subnormal output tests) pass cleanly.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T06:23:23Z.
Review: APPROVED
Tested
eb30a0don Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (265 passed, 0 failed).I checked the subnormal path by hand:
ein[-10, 0], the value issig · 2^(e - 15 - 23), and a half subnormal ism · 2^-24. Som = sig >> (14 - e), which is the shift used.e = -10(shift 24),q = 0. Exactly2^-25is a tie and rounds to even (0), and anything above it rounds to 1.e = 0the rounding can carrymto0x400. That is the bit pattern of the smallest normal, so the carry encodes correctly with no special case.2^-25still flush to signed zero, and the normal path is unchanged.No issues found.
AI-assisted (Claude Code).