From 5a320cca19ed5c7e34c3953481f6a5033958dca5 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Wed, 20 Mar 2024 18:16:11 -0400 Subject: [PATCH] =?UTF-8?q?Buffer=20bindings=20in=20shader=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Will need to be reworked --- .../CodeGen/Msl/MslGenerator.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs index 5e6f344fc..8fa9df0ca 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs @@ -24,13 +24,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl if (info.Functions.Count != 0) { - for (int i = 1; i < info.Functions.Count; i++) - { - context.AppendLine($"{GetFunctionSignature(context, info.Functions[i], parameters.Definitions.Stage)};"); - } - - context.AppendLine(); - for (int i = 1; i < info.Functions.Count; i++) { PrintFunction(context, info.Functions[i], parameters.Definitions.Stage); @@ -58,7 +51,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl context.LeaveScope(); } - private static string GetFunctionSignature(CodeGenContext context, StructuredFunction function, ShaderStage stage, bool isMainFunc = false) + private static string GetFunctionSignature( + CodeGenContext context, + StructuredFunction function, + ShaderStage stage, + bool isMainFunc = false) { string[] args = new string[function.InArguments.Length + function.OutArguments.Length]; @@ -115,6 +112,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl args = args.Prepend("KernelIn in [[stage_in]]").ToArray(); } } + + foreach (var constantBuffer in context.Properties.ConstantBuffers.Values) + { + args = args.Append($"constant float4 *{constantBuffer.Name} [[buffer({constantBuffer.Binding})]]").ToArray(); + } + + foreach (var storageBuffers in context.Properties.StorageBuffers.Values) + { + args = args.Append($"device float4 *{storageBuffers.Name} [[buffer({storageBuffers.Binding})]]").ToArray(); + } } return $"{funcKeyword} {returnType} {funcName ?? function.Name}({string.Join(", ", args)})";