mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 08:19:56 -04:00
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>
This commit is contained in:
@@ -99,8 +99,8 @@ def prepare_sources() -> Path:
|
||||
for junk in list(src.glob("src/*/obj")) + list(src.glob("src/*/bin")):
|
||||
shutil.rmtree(junk)
|
||||
patches = sorted((XLATE / "patches").glob("*.patch"))
|
||||
if len(patches) != 29:
|
||||
sys.exit(f"expected 29 patches, found {len(patches)}")
|
||||
if len(patches) != 31:
|
||||
sys.exit(f"expected 31 patches, found {len(patches)}")
|
||||
for patch in patches:
|
||||
# git apply works outside a repository when given a directory; --check first so a failure names the patch.
|
||||
for extra in (["--check"], []):
|
||||
|
||||
26
tools/xlate/patches/0031-nan-safe-min-max-clamp.patch
Normal file
26
tools/xlate/patches/0031-nan-safe-min-max-clamp.patch
Normal file
@@ -0,0 +1,26 @@
|
||||
--- 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;
|
||||
|
||||
14
tools/xlate/patches/0032-shadow-gather-per-tap-offsets.patch
Normal file
14
tools/xlate/patches/0032-shadow-gather-per-tap-offsets.patch
Normal file
@@ -0,0 +1,14 @@
|
||||
--- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs
|
||||
+++ b/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs
|
||||
@@ -431,7 +431,10 @@
|
||||
|
||||
LinkedListNode<INode> oldNode = node;
|
||||
|
||||
- if (isGather && !isShadow && hasOffsets)
|
||||
+ // NX2NAVI: depth-compare gathers too. With per-tap offsets (TLD4.PTP) the else branch below adds only tap 0's
|
||||
+ // offset, so a shadow map's four taps all came from one place (blocky shadow edges); one gather per tap with
|
||||
+ // that tap's offset keeps its compared texel, the reference value staying in the copied sources.
|
||||
+ if (isGather && hasOffsets)
|
||||
{
|
||||
Operand[] newSources = new Operand[sources.Length];
|
||||
|
||||
Reference in New Issue
Block a user