gpu,shader: port NaN-safe compose clamp and pixel HDR range clamp #534

Merged
Wiktorxd-1 merged 1 commit from upstream-pr/534 into main 2026-11-28 19:39:39 +00:00
Wiktorxd-1 commented 2026-11-28 00:27:11 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Wiktorxd-1 on 2026-11-28T00:27:11Z.


What this fixes

Ported two visual-artifact fixes from aki-gta6/aki-runtime (33c21b9, 01f6f31) by way of ProjectLeonida/mandy (a8d2f48, 1411b6c, GPL-3.0):

  1. Two-plane composer NaN black specks (crates/victory-gpu/src/compose.rs): saturate(NaN) evaluates to 0.0 (black) in HLSL, turning NaNs from upscaling or frame generation into black specks / black sun glints. clean1() uses a bit-level NaN/Inf check ((asuint(x) & 0x7FFFFFFFu) > 0x7F800000u ? 1.0 : saturate(x)) so NaN and +Inf clamp to 1.0 instead of black (VICTORY_COMPOSE_NAN=0 restores plain saturate).
  2. Pixel HDR range clamp (crates/victory-shader/src/emit/lower.rs): The title renders light into R9G9B9E5 targets (clamped at 65408 on console), whereas the host uses 16-bit float targets where values above 65504 become +Inf, which the title's tonemapper turns black (black sun / black glitter / dark patches). clamp_hdr() holds pixel float colour outputs to [-65024, 65024] and maps NaN to 65024.0 (VICTORY_HDR_CLAMP=0 disables it).

The commits

  1. Port NaN-safe composer clamp (VICTORY_COMPOSE_NAN) and pixel HDR range clamp (VICTORY_HDR_CLAMP).

Tests

  • cargo test --locked -p victory-shader --lib emit::tests (passed, 0 failed)
  • cargo test --locked -p victory-gpu --lib descriptor::host::tests (47 passed; 0 failed)
  • cargo build --release --locked -p victory (succeeded in 1m 30s)

Setup

NVIDIA GeForce RTX 5070, driver 621.14.0, Windows 11 (10.0.26300). My own dump: <game dir>. No game files are attached or quoted.

This change and its testing were done with an AI assistant (Antigravity), and I checked the results on my machine.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5534910349 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/534). Originally posted by [Wiktorxd-1](https://github.com/Wiktorxd-1) on 2026-11-28T00:27:11Z. --- ## What this fixes Ported two visual-artifact fixes from `aki-gta6/aki-runtime` (`33c21b9`, `01f6f31`) by way of `ProjectLeonida/mandy` (`a8d2f48`, `1411b6c`, GPL-3.0): 1. **Two-plane composer `NaN` black specks (`crates/victory-gpu/src/compose.rs`)**: `saturate(NaN)` evaluates to `0.0` (black) in HLSL, turning `NaN`s from upscaling or frame generation into black specks / black sun glints. `clean1()` uses a bit-level NaN/Inf check (`(asuint(x) & 0x7FFFFFFFu) > 0x7F800000u ? 1.0 : saturate(x)`) so `NaN` and `+Inf` clamp to `1.0` instead of black (`VICTORY_COMPOSE_NAN=0` restores plain `saturate`). 2. **Pixel HDR range clamp (`crates/victory-shader/src/emit/lower.rs`)**: The title renders light into `R9G9B9E5` targets (clamped at `65408` on console), whereas the host uses 16-bit float targets where values above `65504` become `+Inf`, which the title's tonemapper turns black (black sun / black glitter / dark patches). `clamp_hdr()` holds pixel float colour outputs to `[-65024, 65024]` and maps `NaN` to `65024.0` (`VICTORY_HDR_CLAMP=0` disables it). ## The commits 1. **Port NaN-safe composer clamp (`VICTORY_COMPOSE_NAN`) and pixel HDR range clamp (`VICTORY_HDR_CLAMP`)**. ## Tests - `cargo test --locked -p victory-shader --lib emit::tests` (passed, 0 failed) - `cargo test --locked -p victory-gpu --lib descriptor::host::tests` (`47 passed; 0 failed`) - `cargo build --release --locked -p victory` (succeeded in `1m 30s`) ## Setup NVIDIA GeForce RTX 5070, driver `621.14.0`, Windows 11 (`10.0.26300`). My own dump: `<game dir>`. No game files are attached or quoted. This change and its testing were done with an AI assistant (Antigravity), and I checked the results on my machine.
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
trustno1-coder/VIctory-NVIDIA!534
No description provided.