From 17c31c06b7c33e88d4c9282a9f902c7f0550856e Mon Sep 17 00:00:00 2001 From: Thog Date: Fri, 7 Dec 2018 01:01:41 +0100 Subject: [PATCH 1/3] Move MaxUboSize definition This fix a crash on Ryujinx.ShaderTools caused by the absence of an OpenGL context. --- Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs | 2 +- Ryujinx.Graphics/Gal/Shader/GlslDecl.cs | 3 --- Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 8 ++++++-- Ryujinx.ShaderTools/Program.cs | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs index b45a3a3a5a52..10a9120df2b3 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs @@ -53,7 +53,7 @@ public void Create(IGalMemory Memory, long VpAPos, long Key, GalShaderType Type) { GlslProgram Program; - GlslDecompiler Decompiler = new GlslDecompiler(); + GlslDecompiler Decompiler = new GlslDecompiler(OGLLimit.MaxUboSize); int ShaderDumpIndex = ShaderDumper.DumpIndex; diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs index f1b63a8da3b4..b144cef30658 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs @@ -1,4 +1,3 @@ -using Ryujinx.Graphics.Gal.OpenGL; using System; using System.Collections.Generic; @@ -50,8 +49,6 @@ class GlslDecl public const string SsyStackName = "ssy_stack"; public const string SsyCursorName = "ssy_cursor"; - public static int MaxUboSize => OGLLimit.MaxUboSize / 16; - private string[] StagePrefixes = new string[] { "vp", "tcp", "tep", "gp", "fp" }; private string StagePrefix; diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index 5b62ac3a6eb3..83a4458f447a 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -31,7 +31,9 @@ private enum OperType private StringBuilder SB; - public GlslDecompiler() + public static int MaxUboSize { get; private set; } + + public GlslDecompiler(int MaxUboSize) { InstsExpr = new Dictionary() { @@ -106,6 +108,8 @@ public GlslDecompiler() { ShaderIrInst.Utof, GetUtofExpr }, { ShaderIrInst.Xor, GetXorExpr } }; + + GlslDecompiler.MaxUboSize = MaxUboSize / 16; } public GlslProgram Decompile( @@ -259,7 +263,7 @@ private void PrintDeclUniforms() { SB.AppendLine($"layout (std140) uniform {DeclInfo.Name} {{"); - SB.AppendLine($"{IdentationStr}vec4 {DeclInfo.Name}_data[{GlslDecl.MaxUboSize}];"); + SB.AppendLine($"{IdentationStr}vec4 {DeclInfo.Name}_data[{MaxUboSize}];"); SB.AppendLine("};"); } diff --git a/Ryujinx.ShaderTools/Program.cs b/Ryujinx.ShaderTools/Program.cs index 3597f25624a0..9b55f964a716 100644 --- a/Ryujinx.ShaderTools/Program.cs +++ b/Ryujinx.ShaderTools/Program.cs @@ -11,7 +11,7 @@ static void Main(string[] args) { if (args.Length == 2) { - GlslDecompiler Decompiler = new GlslDecompiler(); + GlslDecompiler Decompiler = new GlslDecompiler(65536); GalShaderType ShaderType = GalShaderType.Vertex; From d7bfe1b7a503d499515b0a734d1ba0b4f726b4a3 Mon Sep 17 00:00:00 2001 From: Thog Date: Fri, 7 Dec 2018 01:11:24 +0100 Subject: [PATCH 2/3] Use a constant for the value in ShaderTools --- Ryujinx.ShaderTools/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Ryujinx.ShaderTools/Program.cs b/Ryujinx.ShaderTools/Program.cs index 9b55f964a716..30fa71aea238 100644 --- a/Ryujinx.ShaderTools/Program.cs +++ b/Ryujinx.ShaderTools/Program.cs @@ -7,11 +7,13 @@ namespace Ryujinx.ShaderTools { class Program { + private static readonly int MaxUboSize = 65536; + static void Main(string[] args) { if (args.Length == 2) { - GlslDecompiler Decompiler = new GlslDecompiler(65536); + GlslDecompiler Decompiler = new GlslDecompiler(MaxUboSize); GalShaderType ShaderType = GalShaderType.Vertex; From 27ffbc3b68eff8dedf980df0b7be7e5148def97f Mon Sep 17 00:00:00 2001 From: Thog Date: Mon, 17 Dec 2018 16:07:52 +0100 Subject: [PATCH 3/3] Address comments --- Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index 83a4458f447a..92bdd658cefa 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -31,7 +31,7 @@ private enum OperType private StringBuilder SB; - public static int MaxUboSize { get; private set; } + public int MaxUboSize { get; } public GlslDecompiler(int MaxUboSize) { @@ -109,7 +109,7 @@ public GlslDecompiler(int MaxUboSize) { ShaderIrInst.Xor, GetXorExpr } }; - GlslDecompiler.MaxUboSize = MaxUboSize / 16; + this.MaxUboSize = MaxUboSize / 16; } public GlslProgram Decompile(