From 27effab9893a2d85e4693f4cd60f86602d38e46a Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 3 Aug 2023 09:21:32 -0400 Subject: [PATCH] Warn when generating unsupported shader --- .../CodeGen/Msl/CodeGenContext.cs | 2 +- src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs | 1 - src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs | 9 ++++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/CodeGenContext.cs index a84d99a04..f41e39625 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/CodeGenContext.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/CodeGenContext.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl public CodeGenContext(StructuredProgramInfo info, ShaderConfig config) { Info = info; - Config = Config; + Config = config; _sb = new StringBuilder(); } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs index 47a8b477f..11d46278e 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs @@ -1,4 +1,3 @@ -using Ryujinx.Graphics.Shader.CodeGen.Glsl; using Ryujinx.Graphics.Shader.StructuredIr; namespace Ryujinx.Graphics.Shader.CodeGen.Msl diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs index 0dc82390f..71196b124 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs @@ -1,3 +1,4 @@ +using Ryujinx.Common.Logging; using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.Translation; @@ -7,7 +8,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl { public static string Generate(StructuredProgramInfo info, ShaderConfig config) { - CodeGenContext context = new CodeGenContext(info, config); + if (config.Stage is not (ShaderStage.Vertex or ShaderStage.Fragment or ShaderStage.Compute)) + { + Logger.Warning?.Print(LogClass.Gpu, $"Attempted to generate unsupported shader type {config.Stage}!"); + return ""; + } + + CodeGenContext context = new(info, config); Declarations.Declare(context, info);