From 69a9de33d37de03693a4a4f6f51aead63b0c6334 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Sat, 20 May 2023 14:52:26 +0100 Subject: [PATCH] SPIR-V: Only allow implicit LOD sampling on fragment (#5026) --- .../Shader/DiskCache/DiskCacheHostStorage.cs | 2 +- .../CodeGen/Spirv/Instructions.cs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs index ee7714521..6a81720c0 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache private const ushort FileFormatVersionMajor = 1; private const ushort FileFormatVersionMinor = 2; private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor; - private const uint CodeGenVersion = 4578; + private const uint CodeGenVersion = 5027; private const string SharedTocFileName = "shared.toc"; private const string SharedDataFileName = "shared.data"; diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs index 5521fa5c9..6da8f29d1 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs @@ -1623,7 +1623,19 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv if (hasLodBias) { - lodBias = Src(AggregateType.FP32); + lodBias = Src(AggregateType.FP32); + } + + if (!isGather && !intCoords && !isMultisample && !hasLodLevel && !hasDerivatives && context.Config.Stage != ShaderStage.Fragment) + { + // Implicit LOD is only valid on fragment. + // Use the LOD bias as explicit LOD if available. + + lod = lodBias ?? context.Constant(context.TypeFP32(), 0f); + + lodBias = null; + hasLodBias = false; + hasLodLevel = true; } SpvInstruction compIdx = null;