diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs index 5e9f6a3b0..7428c3a31 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs @@ -65,14 +65,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl context.AppendLine("using namespace metal;"); context.AppendLine(); + var fsi = (info.HelperFunctionsMask & HelperFunctionsMask.FSI) != 0; + DeclareInputAttributes(context, info.IoDefinitions.Where(x => IsUserDefined(x, StorageKind.Input))); context.AppendLine(); DeclareOutputAttributes(context, info.IoDefinitions.Where(x => x.StorageKind == StorageKind.Output)); context.AppendLine(); - DeclareBufferStructures(context, context.Properties.ConstantBuffers.Values, true); - DeclareBufferStructures(context, context.Properties.StorageBuffers.Values, false); + DeclareBufferStructures(context, context.Properties.ConstantBuffers.Values, true, fsi); + DeclareBufferStructures(context, context.Properties.StorageBuffers.Values, false, fsi); DeclareTextures(context, context.Properties.Textures.Values); - DeclareImages(context, context.Properties.Images.Values); + DeclareImages(context, context.Properties.Images.Values, fsi); if ((info.HelperFunctionsMask & HelperFunctionsMask.FindLSB) != 0) { @@ -180,7 +182,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl } } - private static void DeclareBufferStructures(CodeGenContext context, IEnumerable buffers, bool constant) + private static void DeclareBufferStructures(CodeGenContext context, IEnumerable buffers, bool constant, bool fsi) { var name = constant ? "ConstantBuffers" : "StorageBuffers"; var addressSpace = constant ? "constant" : "device"; @@ -193,8 +195,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl foreach (BufferDefinition buffer in sortedBuffers) { var needsPadding = buffer.Layout == BufferLayout.Std140; + string fsiSuffix = constant && fsi ? " [[raster_order_group(0)]]" : ""; - argBufferPointers.Add($"{addressSpace} {Defaults.StructPrefix}_{buffer.Name}* {buffer.Name};"); + argBufferPointers.Add($"{addressSpace} {Defaults.StructPrefix}_{buffer.Name}* {buffer.Name}{fsiSuffix};"); context.AppendLine($"struct {Defaults.StructPrefix}_{buffer.Name}"); context.EnterScope(); @@ -271,7 +274,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl context.AppendLine(); } - private static void DeclareImages(CodeGenContext context, IEnumerable images) + private static void DeclareImages(CodeGenContext context, IEnumerable images, bool fsi) { context.AppendLine("struct Images"); context.EnterScope(); @@ -284,7 +287,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl foreach (TextureDefinition image in sortedImages) { var imageTypeName = image.Type.ToMslTextureType(true); - argBufferPointers.Add($"{imageTypeName} {image.Name};"); + string fsiSuffix = fsi ? " [[raster_order_group(0)]]" : ""; + + argBufferPointers.Add($"{imageTypeName} {image.Name}{fsiSuffix};"); } foreach (var pointer in argBufferPointers) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs index 5efc8ee1b..daeb62221 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs @@ -131,9 +131,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions case Instruction.Call: return Call(context, operation); case Instruction.FSIBegin: - return "|| FSI BEGIN ||"; case Instruction.FSIEnd: - return "|| FSI END ||"; + return "// FSI implemented with raster order groups in MSL"; case Instruction.GroupMemoryBarrier: case Instruction.MemoryBarrier: case Instruction.Barrier: diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs index 596f95ddd..49f3c63aa 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs @@ -164,8 +164,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions public static bool NeedsParenthesis(IAstNode node, Instruction pInst, InstInfo pInfo, bool isLhs) { - // If the node isn't a operation, then it can only be a operand, - // and those never needs to be surrounded in parenthesis. + // If the node isn't an operation, then it can only be an operand, + // and those never needs to be surrounded in parentheses. if (node is not AstOperation operation) { // This is sort of a special case, if this is a negative constant,