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

Open
github-bot wants to merge 1 commit from github-bot/gh-534 into main AGit
Owner

@⁠Wiktorxd-1 on GitHub · 2026-11-28 00:27 UTC · original
Wiktorxd-1:fix/compose-nan-and-hdr-clamp → main · +56 −5 · 2 files · 1 commits · open

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.

**@⁠Wiktorxd-1** on GitHub · 2026-11-28 00:27 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/534) `Wiktorxd-1:fix/compose-nan-and-hdr-clamp` → `main` · +56 −5 · 2 files · 1 commits · open ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 00:28:42 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/534/head:github-bot/gh-534'
git switch 'github-bot/gh-534'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-534'
git switch 'github-bot/gh-534'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-534'
git switch 'github-bot/gh-534'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-534'
git switch 'main'
git merge --squash 'github-bot/gh-534'
git switch 'main'
git merge --ff-only 'github-bot/gh-534'
git switch 'main'
git merge 'github-bot/gh-534'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.