GPU: write half subnormals from f32 rectangle outputs #418

Manually merged
github merged 1 commit from gh-pr/418/head into gh-pr/418/base 2026-11-26 04:03:05 +00:00
Owner

@⁠enzoduarte1 on GitHub · 2026-11-24 03:10 UTC · original
enzoduarte1:gpu/half-subnormal-output → main · +30 −1 · 1 files · 1 commits · merged 2026-11-24 08:10 UTC

What

f32_to_half returned signed zero for every exp <= 0, while half_to_f32 does decode half subnormals. An f16 rectangle output with a small value (for example 2^-24, which is exactly 0x0001) 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

  • Windows 11, Rust 1.98.1, 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-existing host.rs warning fixed by PR #355 also appears.
  • rustfmt --edition 2024 --check crates/victory-gpu/src/primitive.rs and git diff --check: clean.
  • cargo xtask policy: 151 files ok. No game files or data taken from them were added.
  • Not tested: cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's /DELAYLOAD flag, which MinGW rejects here; the same failure occurs on unmodified main.

Checklist

  • cargo fmt, cargo clippy --workspace --all-targets and cargo test --workspace pass — see the toolchain limitations above; the changed crate is clean.
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
**@⁠enzoduarte1** on GitHub · 2026-11-24 03:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/418) `enzoduarte1:gpu/half-subnormal-output` → `main` · +30 −1 · 1 files · 1 commits · merged 2026-11-24 08:10 UTC ## What `f32_to_half` returned signed zero for every `exp <= 0`, while `half_to_f32` does decode half subnormals. An f16 rectangle output with a small value (for example `2^-24`, which is exactly `0x0001`) 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 - Windows 11, Rust 1.98.1, `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-existing `host.rs` warning fixed by PR #355 also appears. - `rustfmt --edition 2024 --check crates/victory-gpu/src/primitive.rs` and `git diff --check`: clean. - `cargo xtask policy`: 151 files ok. No game files or data taken from them were added. - Not tested: `cargo test -p victory-loader --test load_probe`. Its fixture passes MSVC's `/DELAYLOAD` flag, which MinGW rejects here; the same failure occurs on unmodified `main`. ## Checklist - [ ] `cargo fmt`, `cargo clippy --workspace --all-targets` and `cargo test --workspace` pass — see the toolchain limitations above; the changed crate is clean. - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:03:03 +00:00
github manually merged commit eb30a0d9f4 into gh-pr/418/base 2026-11-26 04:03:05 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!418
No description provided.