From e2a612b1141c496044846c8af0fdc19079ce084a Mon Sep 17 00:00:00 2001 From: KeatonTheBot Date: Mon, 24 Aug 2026 19:21:19 +0000 Subject: [PATCH] macOS: Fix NaN texture coordinates resolving toward max on Apple GPUs (#182) This PR fixes Animal Crossing: New Horizons backdrops on Apple Silicon being white instead of black. Credit to [mtmasantana](https://github.com/mtmasantana) for the fix. More info on the Issues page: https://github.com/Ryubing/Issues/issues/476 ![acnh-white-bg](/attachments/980555c7-1796-4999-a98e-aa16d43fc533) ![acnh-black-bg-fixed](/attachments/26464cfe-a9e4-43ab-886c-aae90834ee08) Co-authored-by: mtmasantana <245373187+mtmasantana@users.noreply.github.com> Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/182 --- .../CodeGen/Spirv/Instructions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs index 77a23d1f2..79383ec4d 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs @@ -1241,6 +1241,23 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv SpvInstruction pCoords = AssemblePVector(pCount); + if (!intCoords) + { + SpvInstruction nfFp32 = context.TypeFP32(); + SpvInstruction nfType = pCount > 1 ? context.TypeVector(nfFp32, pCount) : nfFp32; + SpvInstruction nfZero = context.Constant(nfFp32, 0f); + + if (pCount > 1) + { + SpvInstruction[] nfElems = new SpvInstruction[pCount]; + for (int nfI = 0; nfI < pCount; nfI++) { nfElems[nfI] = nfZero; } + nfZero = context.ConstantComposite(nfType, nfElems); + } + + SpvInstruction nfBool = pCount > 1 ? context.TypeVector(context.TypeBool(), pCount) : context.TypeBool(); + pCoords = context.Select(nfType, context.IsNan(nfBool, pCoords), nfZero, pCoords); + } + SpvInstruction AssembleDerivativesVector(int count) { if (count > 1)