Preserve NaN in HDR diagnostic captures #2050
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2052"
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 DoubleD17 on 2026-11-25T04:09:41Z.
Preserve NaN when decoding HDR capture channels with exponent 31 and a nonzero mantissa. The existing conversion maps NaN to zero and positive infinity to 255 in the RGBA buffer.
Synthetic CPU tests on Windows 11 x64 with Rust 1.98.1 MSVC passed two of five cases on the base with the same fixture and five of five on candidate
86ac6c76a6. They cover both affected formats through RGBA conversion. The fixture stops at the RGBA buffer and does not exercise PNG output or GPU execution.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:17:30Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
NaN preserved in HDR diagnostic captures — diagnostic-path correctness; pairs with #1994's denormal handling theme.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:50:06Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-gpu --features diagnostics --lib capture::— passed (includinghalf_classifies_special_and_finite_values,packed_float_classifies_special_and_finite_values, andhdr_targets_render_nan_and_infinity_as_distinct_channel_values)cargo clippy -p victory-gpu --features diagnostics --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean classification and distinct rendering of NaN and infinity values in HDR diagnostic captures. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T04:15:11Z.
I checked the saved PNGs at
86ac6c76against940d32f6. In each revision I compiled the conversion and PNG-writing functions fromcapture.rsin a standalone CPU harness. The input was two padded rows of ten texels, with each value repeated twice so it survives the writer's downsampling.For R16G16B16A16_FLOAT, R11G11B10_FLOAT and R16_FLOAT, a positive NaN changed from white to black. For R16G16_FLOAT it changed from yellow to black (the missing blue channel is zero). The four controls (+infinity, 0.5, zero and one) kept their original RGB bytes. I checked the PNG header, chunk CRCs and decompressed scanline.
I also compared every input to both float helpers against Python's binary16 decoder, left-aligning the 5- and 6-bit mantissas for the unsigned formats. Base had 2,046 mismatches out of 65,536 half encodings, 31/1,024 for the 5-bit mantissa and 63/2,048 for the 6-bit mantissa. The PR had zero in all three sets. NaNs were compared by classification; all other outputs were compared as f32 bits.
AI-assisted. These checks cover the CPU capture path through PNG output; GPU readback was outside the test.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:22:25Z.
Automated triage for the maintainers.
Merge candidate.
This fixes a decoding bug in the diagnostic texture dumper. In
crates/victory-gpu/src/capture.rs,halfandsmall_floatdecoded every exponent-31 value as infinity. In colour dumps,to_rgbathen shows a NaN as full white, the same as +Inf. The PR returns NaN when the exponent is 31 and the mantissa is nonzero, which follows the IEEE binary16 encoding and the R11G11B10 float encoding. Into_rgba, a NaN then scales to 0 (NaN as u8) and is already left out of the low/high/percentile statistics and counted innot_finite.I worked through the new tests by hand: the bit patterns and expected bytes (including 0.5 → 127 at the p99 scale of 1.0) are right, and they check against the encoding rather than against what the code happens to output. The change only affects debug captures and does not change emulation behaviour. No other open PR changes these helpers.
CI: passing (
check).Recommending a look, not approving.
Generated by Claude Code