From 935a3ced84f85f24886978234a13e93315fc5661 Mon Sep 17 00:00:00 2001 From: Infina <49457443+InfinaMii@users.noreply.github.com> Date: Tue, 3 Mar 2026 12:40:28 +0000 Subject: [PATCH 1/3] Run shader .exe files with WINE on non-Windows platforms - Execute gx2shader-decompiler.exe and spirv-cross.exe with WINE if the platform isnt Windows to avoid crashes when trying to open Wii U files --- .../ShaderLoaders/CafeShaderDecoder.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs b/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs index f7d6aff..abc7876 100644 --- a/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs +++ b/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs @@ -7,6 +7,7 @@ using Toolbox.Core; using Toolbox.Core.IO; using System.Diagnostics; +using System.Runtime.InteropServices; using GLFrameworkEngine; using OpenTK; using OpenTK.Graphics.OpenGL; @@ -197,8 +198,15 @@ static string ConvertStages(List stages) File.WriteAllBytes(Path.Combine(Runtime.ExecutableDir,"GFD",stage.Name), stage.Data); ProcessStartInfo start = new ProcessStartInfo(); - start.FileName = "GFD/gx2shader-decompiler.exe"; - start.WorkingDirectory = System.IO.Path.Combine(Runtime.ExecutableDir, "GFD"); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + start.FileName = "GFD/gx2shader-decompiler.exe"; + else + { + start.FileName = "wine"; + start.Arguments += "GFD/gx2shader-decompiler.exe "; + } + + start.WorkingDirectory = Path.Combine(Runtime.ExecutableDir, "GFD"); foreach (var stage in stages) { if (!File.Exists(Path.Combine(Runtime.ExecutableDir,"GFD",stage.Name))) @@ -263,7 +271,13 @@ static string SPIRV2GLSL(string filePath, string output) string remapFlags = ""; ProcessStartInfo start = new ProcessStartInfo(); - start.FileName = $"GFD/spirv-cross.exe"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + start.FileName = "GFD/spirv-cross.exe"; + else + { + start.FileName = "wine"; + start.Arguments += "GFD/spirv-cross.exe"; + } start.WorkingDirectory = Runtime.ExecutableDir; start.Arguments = $"{AddQuotesIfRequired(filePath)} {remapFlags} --no-es --extension GL_ARB_shader_storage_buffer_object --extension GL_ARB_separate_shader_objects --no-420pack-extension --no-support-nonzero-baseinstance --version 440 --output {AddQuotesIfRequired(output)}"; start.UseShellExecute = false; From ecee09e29cd2f74b8380710a9ba1c412106af599 Mon Sep 17 00:00:00 2001 From: Infina <49457443+InfinaMii@users.noreply.github.com> Date: Tue, 3 Mar 2026 14:30:27 +0000 Subject: [PATCH 2/3] Update CafeShaderDecoder.cs Correctly specify executable path for wine --- .../ShaderTools/ShaderLoaders/CafeShaderDecoder.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs b/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs index abc7876..993dcd6 100644 --- a/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs +++ b/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs @@ -203,7 +203,7 @@ static string ConvertStages(List stages) else { start.FileName = "wine"; - start.Arguments += "GFD/gx2shader-decompiler.exe "; + start.Arguments += $"\'{Path.Combine(Runtime.ExecutableDir, "GFD", "gx2shader-decompiler.exe")}\' "; } start.WorkingDirectory = Path.Combine(Runtime.ExecutableDir, "GFD"); @@ -218,6 +218,7 @@ static string ConvertStages(List stages) start.RedirectStandardOutput = true; start.CreateNoWindow = true; start.WindowStyle = ProcessWindowStyle.Hidden; + Console.WriteLine(start.FileName + ' ' + start.Arguments); using (Process process = Process.Start(start)) { using (StreamReader reader = process.StandardOutput) @@ -276,7 +277,7 @@ static string SPIRV2GLSL(string filePath, string output) else { start.FileName = "wine"; - start.Arguments += "GFD/spirv-cross.exe"; + start.Arguments += $"\'{Path.Combine(Runtime.ExecutableDir, "GFD", "spirv-cross.exe")}\' "; } start.WorkingDirectory = Runtime.ExecutableDir; start.Arguments = $"{AddQuotesIfRequired(filePath)} {remapFlags} --no-es --extension GL_ARB_shader_storage_buffer_object --extension GL_ARB_separate_shader_objects --no-420pack-extension --no-support-nonzero-baseinstance --version 440 --output {AddQuotesIfRequired(output)}"; From 9b644973430422fe473f0a2471d4b5edb4a79114 Mon Sep 17 00:00:00 2001 From: Infina <49457443+InfinaMii@users.noreply.github.com> Date: Tue, 3 Mar 2026 15:31:02 +0000 Subject: [PATCH 3/3] Fix arguments - Update exe path argument to include quotes rather than apostrophes (Process.Start splits lines at space unless they are contained within quotes) - Prevent exe path argument from being replaced by spirv arguments - Remove debug WriteLine call --- .../ShaderTools/ShaderLoaders/CafeShaderDecoder.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs b/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs index 993dcd6..321134c 100644 --- a/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs +++ b/Plugins/CafeLibrary/ShaderTools/ShaderLoaders/CafeShaderDecoder.cs @@ -203,7 +203,7 @@ static string ConvertStages(List stages) else { start.FileName = "wine"; - start.Arguments += $"\'{Path.Combine(Runtime.ExecutableDir, "GFD", "gx2shader-decompiler.exe")}\' "; + start.Arguments += $"\"{Path.Combine(Runtime.ExecutableDir, "GFD", "gx2shader-decompiler.exe")}\" "; } start.WorkingDirectory = Path.Combine(Runtime.ExecutableDir, "GFD"); @@ -218,7 +218,6 @@ static string ConvertStages(List stages) start.RedirectStandardOutput = true; start.CreateNoWindow = true; start.WindowStyle = ProcessWindowStyle.Hidden; - Console.WriteLine(start.FileName + ' ' + start.Arguments); using (Process process = Process.Start(start)) { using (StreamReader reader = process.StandardOutput) @@ -277,10 +276,10 @@ static string SPIRV2GLSL(string filePath, string output) else { start.FileName = "wine"; - start.Arguments += $"\'{Path.Combine(Runtime.ExecutableDir, "GFD", "spirv-cross.exe")}\' "; + start.Arguments += $"\"{Path.Combine(Runtime.ExecutableDir, "GFD", "spirv-cross.exe")}\" "; } start.WorkingDirectory = Runtime.ExecutableDir; - start.Arguments = $"{AddQuotesIfRequired(filePath)} {remapFlags} --no-es --extension GL_ARB_shader_storage_buffer_object --extension GL_ARB_separate_shader_objects --no-420pack-extension --no-support-nonzero-baseinstance --version 440 --output {AddQuotesIfRequired(output)}"; + start.Arguments += $"{AddQuotesIfRequired(filePath)} {remapFlags} --no-es --extension GL_ARB_shader_storage_buffer_object --extension GL_ARB_separate_shader_objects --no-420pack-extension --no-support-nonzero-baseinstance --version 440 --output {AddQuotesIfRequired(output)}"; start.UseShellExecute = false; start.RedirectStandardOutput = true; start.CreateNoWindow = true;