Round rectangle half-float attributes to even and preserve NaNs #2702
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2704"
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 VlREX on 2026-11-25T18:28:39Z.
The CPU rectangle expansion rounded normal half-float midpoints upward even when the lower neighbour was even. It also converted NaNs into infinities. Correct both conversions when encoding the generated fourth vertex. The new tests cover all adjacent positive finite half pairs and both signs at every midpoint, plus three NaN encodings. Both tests failed before the fix. All 11 primitive module tests passed in an isolated Windows GNU run.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:43:42Z.
Independent Windows 11 + WARP verification and IEEE-754 review of
0544d491(on13f91ca):Verification (
rustc 1.98.1MSVC)cargo clippy --locked -p victory-gpu --all-targets -- -D warningsand--features diagnostics: 0 warnings.cargo test --locked -p victory-gpu --lib primitive::tests: 11 passed, 0 failed (includinghalf_midpoints_round_to_the_even_neighbouracross all0..0x7bffpositive/negative midpoints andhalf_nan_attributes_remain_nan).VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 200 passed, 0 failed, 1 ignored.Review Notes
sign | 0x7e00 | (man >> 13)keeps sign/top payload bits and ensures sNaNs with only low payload bits never collapse to±Inf),-0.0sign preservation, subnormal round-to-nearest-even (exp == -10exact midpoint to0,exp == 0max subnormal carry0x3ff + 1 -> 0x0400), normal round-to-nearest-even (rounding_bias = 0xfff + ((man >> 13) & 1)), and overflow at65520.0 -> ±Inf.victory-shader/src/emit/rect.rs).Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:50:08Z.
Both fixes are textbook: the 0xfff + ((man>>13)&1) bias is round-to-nearest-even, and the NaN path keeps sign + payload under a set quiet bit instead of collapsing to infinity. Exhaustive adjacent-pair coverage is the right test here.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T18:56:58Z.
Independent WARP/CPU verification (claim: Marvisak/VIctory#1633)
0544d491f469debd5a7b5d367e911121e87b7c1c/origin/main:13f91caee25f2fdf2c062be5f7a27f058e51cbcagit merge-tree --write-tree origin/main <head>merges cleanly; no prioroni-swrcomment on this head.VICTORY_WARP=1+VICTORY_D3D12_WARP=1(WARP only, no physical GPU, no game files/dumps/retail hashes),dxil.dll1.8.2502.11 (Windows SDK 10.0.26100.0, viaVICTORY_DXIL), rustc 1.98.1 (48a229cea 2026-09-01), debug profile,--locked.Commands / results (baseline =
origin/main, same environment)primitive::tests::half_midpoints_round_to_the_even_neighbourandhalf_nan_attributes_remain_nanok.Negative control: with
rounding_biasreverted to0x1000and the NaN branch disabled, both new tests FAIL (the existing third primitive test still passes); reverted afterwards.Code review: No bugs found. Round-to-even via
0xfff + lsbis correct for normals including carry into the exponent / infinity; subnormals already rounded to even. NaN keeps its sign, is forced quiet (0x7e00) and keeps the top 10 payload bits, so a signaling NaN with payload only in the low bits becomes a quiet NaN, never infinity. The midpoint test covers every adjacent half pair 0..0x7bff incl. subnormals; the largest-finite-to-infinity midpoint is not covered.Not tested: physical GPU hardware (RX 7800 XT or any), retail game run, release build, other crates.
AI use: Claude Code (Claude Sonnet 5.5) ran the commands and reviewed the diff; the results above are from the actual runs.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T19:26:46Z.
Independent CPU-only verification on Windows / Rust 1.100.0 / MSVC,
--locked,CARGO_BUILD_JOBS=2, no game files and no GPU.cargo test --locked -p victory-gpu --lib half --quiet→ 3 passed, 0 failed (198 filtered).cargo test --locked -p victory-gpu --lib primitive::tests --quiet→ 11 passed, 0 failed (187 filtered).half_midpoints_round_to_the_even_neighbour,half_nan_attributes_remain_nan) are absent fromorigin/mainincrates/victory-gpu/src/primitive.rs(git grepreturned no matches).git diff --check origin/main..HEADwas clean for the PR branch.No blocking findings. The only output noise is two pre-existing deprecation warnings in
crates/victory-gpu/src/object.rs(Atomic::fetch_update), unrelated to this diff.AI-assisted (Hy4 flash).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:21:44Z.
Automated triage for the maintainers.
Merge candidate (recommend a look).
f32_to_halfincrates/victory-gpu/src/primitive.rs(used when the CPU writes the fourth vertex of a rectangle with half-float attributes) rounded normal midpoints up regardless of parity and turned NaNs into infinities. Now normals use the standard round-to-nearest-even bias (0xfff + lsb), matching the subnormal path that already rounded to even, and NaNs stay quiet NaNs with their sign. I checked the overflow edge: 65520.0 still becomes infinity, as the existing test expects, and infinite inputs still give infinity because the NaN test comes first. The new test checks every adjacent pair of finite halves against the even neighbour, so it compares against IEEE rounding rather than repeating the code.CI:
checkpassing on this head.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:23:02Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-gpu --lib primitive::tests: 11 passed, 0 failed (including newhalf_midpoints_round_to_the_even_neighbourandhalf_nan_attributes_remain_nan).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.