Round rectangle half-float attributes to even and preserve NaNs #2704
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!2704
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@VlREX on GitHub · 2026-11-25 18:28 UTC · original
VlREX:fix/rect-half-rounding→main· +25 −1 · 1 files · 1 commits · openThe 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.
@fuzeofficlal on GitHub · 2026-11-25 18:43 UTC · original
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).@kotekompotek on GitHub · 2026-11-25 18:50 UTC · original
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.
@oni-swr on GitHub · 2026-11-25 18:56 UTC · original
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.
@cloph-dsp on GitHub · 2026-11-25 19:26 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 22:21 UTC · original
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
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.