fix(xgameruntime): reject non-finite HDR luminance values in hdr::normalize #374

Merged
Lewandox merged 2 commits from upstream-pr/374 into main 2026-11-26 14:02:50 +00:00
Lewandox commented 2026-11-26 13:44:18 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-26T13:44:18Z.


Summary

Fixes hdr::normalize in crates/anyxboxx-xgameruntime/src/hdr.rs allowing f32::INFINITY through as max_tone_map_luminance (and max_full_frame_tone_map_luminance).

Previously, normalize checked min.is_nan() || max.is_nan() || min < 0.0 || max <= min, so a reported (0.01, +inf, 400.0) bypassed all checks and returned max_tone_map_luminance = +inf to the title's tone mapper. Similarly, full_frame == +inf bypassed the fallback check.

Changes

  • crates/anyxboxx-xgameruntime/src/hdr.rs: Use !is_finite() instead of is_nan() for min, max, and full_frame.
  • Added unit test cases for f32::INFINITY and f32::NEG_INFINITY across min, max, and max_full_frame_tone_map_luminance.

Verification

  • cargo fmt -p anyxboxx-xgameruntime -- --check — pass
  • cargo clippy -p anyxboxx-xgameruntime --no-deps --all-targets -- -D warnings — pass
  • cargo test -p anyxboxx-xgameruntime hdr::tests — all passed, 0 failed
<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6627972277 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/374). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-26T13:44:18Z. --- ## Summary Fixes `hdr::normalize` in `crates/anyxboxx-xgameruntime/src/hdr.rs` allowing `f32::INFINITY` through as `max_tone_map_luminance` (and `max_full_frame_tone_map_luminance`). Previously, `normalize` checked `min.is_nan() || max.is_nan() || min < 0.0 || max <= min`, so a reported `(0.01, +inf, 400.0)` bypassed all checks and returned `max_tone_map_luminance = +inf` to the title's tone mapper. Similarly, `full_frame == +inf` bypassed the fallback check. ### Changes - **`crates/anyxboxx-xgameruntime/src/hdr.rs`**: Use `!is_finite()` instead of `is_nan()` for `min`, `max`, and `full_frame`. - Added unit test cases for `f32::INFINITY` and `f32::NEG_INFINITY` across `min`, `max`, and `max_full_frame_tone_map_luminance`. ### Verification - `cargo fmt -p anyxboxx-xgameruntime -- --check` — pass - `cargo clippy -p anyxboxx-xgameruntime --no-deps --all-targets -- -D warnings` — pass - `cargo test -p anyxboxx-xgameruntime hdr::tests` — all passed, 0 failed
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
LooperSalty/AnyXboxX!374
No description provided.