From 408bd63b08cbde8ba55bb05a39868271a9e40ba4 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 7 Sep 2022 20:25:22 -0300 Subject: [PATCH] Transform shader LDC into constant buffer access if offset is constant (#3672) * Transform shader LDC into constant buffer access if offset is constant * Shader cache version bump --- Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs | 2 +- .../Translation/Optimizations/ConstantFolding.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs index e66d5d6f8c..f020ec4904 100644 --- a/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs +++ b/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 = 3525; + private const uint CodeGenVersion = 3672; private const string SharedTocFileName = "shared.toc"; private const string SharedDataFileName = "shared.data"; diff --git a/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs b/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs index 856a5598d6..092e52a986 100644 --- a/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs +++ b/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs @@ -153,6 +153,10 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations EvaluateFPUnary(operation, (x) => float.IsNaN(x)); break; + case Instruction.LoadConstant: + operation.TurnIntoCopy(Cbuf(operation.GetSource(0).Value, operation.GetSource(1).Value)); + break; + case Instruction.Maximum: EvaluateBinary(operation, (x, y) => Math.Max(x, y)); break;