Files
NX2navi/tools/xlate/patches/0031-nan-safe-min-max-clamp.patch
chrg6 37c06e6894 Sample terrain with the right mip levels, keep NaNs out of min, max and clamp, and give shadow gathers their own tap offsets.
The runtime's TXD gradient transpose (gfx_shader.c patch_txd_transpose) is off for Switch 2 titles: the SM86 lowering
already orders the interleaved derivatives for the translator, so transposing again swapped them back. The
translator's float min, max and clamp are the NaN-safe forms (patch 0031), as Maxwell FMNMX and saturate behave, so a
NaN no longer spreads through lighting and bloom on drivers that pass it on. Depth-compare gathers with per-tap offsets
are split into one gather per tap like the others (patch 0032), where all four taps took the first tap's offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 16:28:53 -05:00

27 lines
1.2 KiB
Diff

--- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs
@@ -171,9 +171,12 @@
IAdd = context.IAdd;
FDiv = context.FDiv;
SDiv = context.SDiv;
- GlslFMax = context.GlslFMax;
+ // NX2NAVI: NaN-safe minimum and maximum. Maxwell FMNMX returns the other operand when one is NaN (and a
+ // saturate takes NaN to 0); GLSL.std.450 FMin, FMax and FClamp may return either, and AMD's Windows compiler
+ // passes the NaN on, so one NaN texel spreads through lighting and bloom. NMin, NMax and NClamp match FMNMX.
+ GlslFMax = context.GlslNMax;
GlslSMax = context.GlslSMax;
- GlslFMin = context.GlslFMin;
+ GlslFMin = context.GlslNMin;
GlslSMin = context.GlslSMin;
FMod = context.FMod;
FMul = context.FMul;
@@ -210,7 +213,7 @@
AtomicXor = context.AtomicXor;
// Ternary
- GlslFClamp = context.GlslFClamp;
+ GlslFClamp = context.GlslNClamp;
GlslSClamp = context.GlslSClamp;
GlslFma = context.GlslFma;