Shaders: opt-in VICTORY_NAN_SCRUB to zero NaN/Inf pixel and float image outputs #3397
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!3397
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3397"
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?
@danielibabet on GitHub · 2026-11-26 22:06 UTC · original
danielibabet:pr/nan-scrub→main· +54 −10 · 3 files · 1 commits · openSummary
Adds an opt-in
VICTORY_NAN_SCRUB=1switch (off by default) to replaceNaNand+/-infinitywith0.0in pixel colour exports andtextureStore.f32UAV writes, plus includes it in theshader_cachebuild key.Why
On NVIDIA GPUs, a single
NaNor+/-infwritten by a pixel or compute shader propagates through bloom, blur, and temporal upscaling passes as persistent black patches or blown-out white regions. Keeping it behind an opt-in switch preserves exact console behaviour by default while making it easy to test and isolate on PC.Credits
Adapted from
trustno1-coder/VIctory-NVIDIA(VICTORY_NAN_SCRUB=1).Verification
cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1(4/4 passed)cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings(clean)cargo xtask policy(191 files ok)@Dukestar69 on GitHub · 2026-11-26 22:29 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).VICTORY_NAN_SCRUBis cleanly isolated behind the switch, tracked in the shader cache key, and leaves default lowering untouched.cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1: 17 passed, 0 failed.cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1: 4 passed, 0 failed.cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Jackster on GitHub · 2026-11-26 22:44 UTC · original
Windows 11,
63bcca4+ this PR, Radeon RX 7900 XTX:cargo test -p victory-shader --lib --features host: 302 passed / 0 failed / 3 ignored (145 s) — the same counts as unpatched63bcca4here.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.No test is added: the switch gates emit (
VICTORY_NAN_SCRUB), and the whole shader suite — including the VALU and semantics tests that run on the device — is unchanged by it when the switch is off. I did not exercise the switch itself (that needs title shaders that produce NaN/Inf outputs). Synthetic only. AI-assisted.@fuzeofficlal on GitHub · 2026-11-26 23:15 UTC · original · approved these changes
Reviewed
1a2e72ccmerged ontomain(63bcca43) — clean opt-in NaN/Inf scrubbing scoped strictly to float pixel color exports and float image stores, with shader-cache isolation.Verification
cargo xtask policy: 191 files ok (crates/victory-shader/src/emit/lower.rsis521,704bytes, within the 512 KiB cap);cargo clippy --locked -p victory-shader -p victory-gpu --all-targets -- -D warnings(both default and--features diagnostics): 0 warnings.victory_shader::emit::nan_scrub()(emit/mod.rs:270) is off by default and hashed intoshader_cache::key(shader_cache.rs:71, 79-85) with unit-test coverage.image_store(lower.rs:8621-8623, which exclusively emitstextureStore.f32) and float pixel color exports (el.comp == 9 && self.s.pixel && matches!(e.target, Target::Color(_))atlower.rs:10090-10103), leaving integer targets, depth exports, and non-pixel stages untouched.dxil.dllprobe (VICTORY_NAN_SCRUB=1and=0):image_store(into anRGBA32FUAV) and pixelSV_Targetfloat exports with[+qNaN, -qNaN, +sNaN, +Inf, -Inf]and finite values[0.5, -1.25, f32::MAX, f32::MIN, -0.0, 42.0]on both RTX 5090 and WARP:VICTORY_NAN_SCRUB=1: all NaN and ±Inf lanes scrubbed to0x00000000on both RTX 5090 and WARP (confirming neither driver foldsFAbs + fcmp uge + select), while finite values passed through unchanged.VICTORY_NAN_SCRUB=0: original NaN/±Inf bit patterns preserved unchanged on both adapters.SV_Target(comp = 5) pixel shader produced identical DXIL size (2182bytes) under both settings; all emitted shaders passeddxil.dllvalidation.LGTM.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 23:48 UTC · original
I exercised the switch on exact
1a2e72cwith the same synthetic image-store program bound first to a float UAV and then to an integer UAV. AtVICTORY_NAN_SCRUB=0, both kept all eight values. At=1, the float output correctly zeroed its four nonfinite values, but the integer UAV also zeroed the four bit patterns that would be nonfinite if read as floats. This reproduced in two app-local WARP processes per setting.Combined follow-up
c15289euses the view-kind metadata from adopted #34031ac4502. It scrubs texture UAV stores when the descriptor names a known float or normalized format. Integer and unknown-format stores retain their values. Three WARP processes per switch setting matched all 24 expected outputs, including signed zero and finite values. The affected shader suite passed 46/46 in both modes. GPU format and cache-key tests, strict Clippy in both configurations, and asset policy passed.@danielibabet, could you take the format guard before the next NVIDIA test? If you fold in the change or regression, please retain the Git author or use
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.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.