diff options
author | gdkchan <gab.dark.100@gmail.com> | 2023-05-20 16:19:26 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-20 16:19:26 -0300 |
commit | 402f05b8ef013807997589ecc0a8ff50267dcd23 (patch) | |
tree | 8e3b06c2ce3e3ccd4b443a4c68365251acc668fa /src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs | |
parent | fb27042e01b0fa110184673d436ec96ec8cf20c7 (diff) |
Replace constant buffer access on shader with new Load instruction (#4646)1.1.811
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs')
-rw-r--r-- | src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs index 6729f077..4caadb73 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations { static class ConstantFolding { - public static void RunPass(Operation operation) + public static void RunPass(ShaderConfig config, Operation operation) { if (!AreAllSourcesConstant(operation)) { @@ -153,8 +153,21 @@ 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)); + case Instruction.Load: + if (operation.StorageKind == StorageKind.ConstantBuffer && operation.SourcesCount == 4) + { + int binding = operation.GetSource(0).Value; + int fieldIndex = operation.GetSource(1).Value; + + if (config.ResourceManager.TryGetConstantBufferSlot(binding, out int cbufSlot) && fieldIndex == 0) + { + int vecIndex = operation.GetSource(2).Value; + int elemIndex = operation.GetSource(3).Value; + int cbufOffset = vecIndex * 4 + elemIndex; + + operation.TurnIntoCopy(Cbuf(cbufSlot, cbufOffset)); + } + } break; case Instruction.Maximum: |