diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 3fdd28b9e7..dd40bb72de 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -197,11 +197,9 @@ namespace Ryujinx.Graphics.Gpu.Shader TranslationFlags.DebugMode | TranslationFlags.Unspecialized; - TranslationConfig translationConfig = new TranslationConfig(0x10000, _dumper.CurrentDumpIndex, flags); - Span code = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize); - program = Translator.Translate(code, translationConfig); + program = Translator.Translate(code, flags); int[] codeCached = MemoryMarshal.Cast(code.Slice(0, program.Size)).ToArray(); @@ -233,8 +231,6 @@ namespace Ryujinx.Graphics.Gpu.Shader TranslationFlags.DebugMode | TranslationFlags.Unspecialized; - TranslationConfig translationConfig = new TranslationConfig(0x10000, _dumper.CurrentDumpIndex, flags); - int[] codeCached = null; if (gpuVaA != 0) @@ -242,7 +238,7 @@ namespace Ryujinx.Graphics.Gpu.Shader Span codeA = _context.MemoryAccessor.Read(gpuVaA, MaxProgramSize); Span codeB = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize); - program = Translator.Translate(codeA, codeB, translationConfig); + program = Translator.Translate(codeA, codeB, flags); // TODO: We should also check "codeA" into account. codeCached = MemoryMarshal.Cast(codeB.Slice(0, program.Size)).ToArray(); @@ -262,7 +258,7 @@ namespace Ryujinx.Graphics.Gpu.Shader { Span code = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize); - program = Translator.Translate(code, translationConfig); + program = Translator.Translate(code, flags); codeCached = MemoryMarshal.Cast(code.Slice(0, program.Size)).ToArray(); diff --git a/Ryujinx.Graphics.Shader/CodeGen/Constants.cs b/Ryujinx.Graphics.Shader/CodeGen/Constants.cs index 10c22c6032..59e9f14584 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Constants.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Constants.cs @@ -3,5 +3,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen static class Constants { public const int MaxShaderStorageBuffers = 16; + + public const int ConstantBufferSize = 0x10000; // In bytes } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index a8cabaaf4a..e8b4496121 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -210,7 +210,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl context.EnterScope(); - string ubSize = "[" + NumberFormatter.FormatInt(context.Config.MaxCBufferSize / 16) + "]"; + string ubSize = "[" + NumberFormatter.FormatInt(Constants.ConstantBufferSize / 16) + "]"; context.AppendLine("vec4 " + OperandManager.GetUbName(context.Config.Stage, cbufSlot) + ubSize + ";"); diff --git a/Ryujinx.Graphics.Shader/ShaderConfig.cs b/Ryujinx.Graphics.Shader/ShaderConfig.cs index 6ab4689a67..3583fa64c7 100644 --- a/Ryujinx.Graphics.Shader/ShaderConfig.cs +++ b/Ryujinx.Graphics.Shader/ShaderConfig.cs @@ -8,7 +8,6 @@ namespace Ryujinx.Graphics.Shader public TranslationFlags Flags { get; } - public int MaxCBufferSize { get; } public int MaxOutputVertices { get; } public OutputTopology OutputTopology { get; } @@ -16,13 +15,11 @@ namespace Ryujinx.Graphics.Shader public ShaderConfig( ShaderStage stage, TranslationFlags flags, - int maxCBufferSize, int maxOutputVertices, OutputTopology outputTopology) { Stage = stage; Flags = flags; - MaxCBufferSize = maxCBufferSize; MaxOutputVertices = maxOutputVertices; OutputTopology = outputTopology; } diff --git a/Ryujinx.Graphics.Shader/Translation/TranslationConfig.cs b/Ryujinx.Graphics.Shader/Translation/TranslationConfig.cs deleted file mode 100644 index e5fa6d14df..0000000000 --- a/Ryujinx.Graphics.Shader/Translation/TranslationConfig.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace Ryujinx.Graphics.Shader.Translation -{ - public struct TranslationConfig - { - public int MaxCBufferSize { get; } - - public int Version { get; } - - public TranslationFlags Flags { get; } - - public TranslationConfig(int maxCBufferSize, int version, TranslationFlags flags) - { - if (maxCBufferSize <= 0) - { - throw new ArgumentOutOfRangeException(nameof(maxCBufferSize)); - } - - MaxCBufferSize = maxCBufferSize; - Version = version; - Flags = flags; - } - } -} \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs index 2f33997cb1..9c1eb08e9b 100644 --- a/Ryujinx.Graphics.Shader/Translation/Translator.cs +++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs @@ -48,10 +48,10 @@ namespace Ryujinx.Graphics.Shader.Translation return code.Slice(0, headerSize + (int)endAddress); } - public static ShaderProgram Translate(Span code, TranslationConfig translationConfig) + public static ShaderProgram Translate(Span code, TranslationFlags flags) { - bool compute = (translationConfig.Flags & TranslationFlags.Compute) != 0; - bool debugMode = (translationConfig.Flags & TranslationFlags.DebugMode) != 0; + bool compute = (flags & TranslationFlags.Compute) != 0; + bool debugMode = (flags & TranslationFlags.DebugMode) != 0; Operation[] ops = DecodeShader( code, @@ -83,25 +83,23 @@ namespace Ryujinx.Graphics.Shader.Translation ShaderConfig config = new ShaderConfig( stage, - translationConfig.Flags, - translationConfig.MaxCBufferSize, + flags, maxOutputVertexCount, outputTopology); return Translate(ops, config, size); } - public static ShaderProgram Translate(Span vpACode, Span vpBCode, TranslationConfig translationConfig) + public static ShaderProgram Translate(Span vpACode, Span vpBCode, TranslationFlags flags) { - bool debugMode = (translationConfig.Flags & TranslationFlags.DebugMode) != 0; + bool debugMode = (flags & TranslationFlags.DebugMode) != 0; Operation[] vpAOps = DecodeShader(vpACode, compute: false, debugMode, out _, out _); Operation[] vpBOps = DecodeShader(vpBCode, compute: false, debugMode, out ShaderHeader header, out int sizeB); ShaderConfig config = new ShaderConfig( header.Stage, - translationConfig.Flags, - translationConfig.MaxCBufferSize, + flags, header.MaxOutputVertexCount, header.OutputTopology); diff --git a/Ryujinx.ShaderTools/Program.cs b/Ryujinx.ShaderTools/Program.cs index c0afa4f164..6fa043a3c1 100644 --- a/Ryujinx.ShaderTools/Program.cs +++ b/Ryujinx.ShaderTools/Program.cs @@ -19,9 +19,7 @@ namespace Ryujinx.ShaderTools byte[] data = File.ReadAllBytes(args[args.Length - 1]); - TranslationConfig translationConfig = new TranslationConfig(0x10000, 0, flags); - - string code = Translator.Translate(data, translationConfig).Code; + string code = Translator.Translate(data, flags).Code; Console.WriteLine(code); }