From c77f3b90a9ac12fa9ac52f9c752024fba103b437 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 1 Aug 2024 14:23:56 +0100 Subject: [PATCH] Fix Non-Float Textures + Image Read + FSI Buffers Fixes Mario Party Superstars --- .../CodeGen/Msl/Declarations.cs | 6 +++--- .../CodeGen/Msl/Instructions/InstGenMemory.cs | 3 +-- src/Ryujinx.Graphics.Shader/SamplerType.cs | 11 +++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs index e05c30282..ed423a60b 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs @@ -222,7 +222,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl BufferDefinition buffer = buffers[i]; var needsPadding = buffer.Layout == BufferLayout.Std140; - string fsiSuffix = constant && fsi ? " [[raster_order_group(0)]]" : ""; + string fsiSuffix = !constant && fsi ? " [[raster_order_group(0)]]" : ""; bufferDec[i] = $"{addressSpace} {Defaults.StructPrefix}_{buffer.Name}* {buffer.Name}{fsiSuffix};"; @@ -285,7 +285,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl { if (texture.Type != SamplerType.None) { - var textureTypeName = texture.Type.ToMslTextureType(); + var textureTypeName = texture.Type.ToMslTextureType(texture.Format.GetComponentType()); if (texture.ArrayLength > 1) { @@ -329,7 +329,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl { TextureDefinition image = images[i]; - var imageTypeName = image.Type.ToMslTextureType(true); + var imageTypeName = image.Type.ToMslTextureType(image.Format.GetComponentType(), true); if (image.ArrayLength > 1) { imageTypeName = $"array<{imageTypeName}, {image.ArrayLength}>"; diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs index f6fa7aa73..da8deb706 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs @@ -251,10 +251,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions _ => string.Empty, }; - texCallBuilder.Append($"{prefix}4({string.Join(", ", cElems)})"); + texCallBuilder.Append($"{prefix}4({string.Join(", ", cElems)}), "); } - texCallBuilder.Append(", "); texCallBuilder.Append(coordsBuilder); if (texOp.Inst == Instruction.ImageAtomic) diff --git a/src/Ryujinx.Graphics.Shader/SamplerType.cs b/src/Ryujinx.Graphics.Shader/SamplerType.cs index 49c5222e4..18285cd70 100644 --- a/src/Ryujinx.Graphics.Shader/SamplerType.cs +++ b/src/Ryujinx.Graphics.Shader/SamplerType.cs @@ -156,7 +156,7 @@ namespace Ryujinx.Graphics.Shader return typeName; } - public static string ToMslTextureType(this SamplerType type, bool image = false) + public static string ToMslTextureType(this SamplerType type, AggregateType aggregateType, bool image = false) { string typeName; @@ -192,7 +192,14 @@ namespace Ryujinx.Graphics.Shader typeName += "_array"; } - return $"{typeName}"; + var format = aggregateType switch + { + AggregateType.S32 => "int", + AggregateType.U32 => "uint", + _ => "float" + }; + + return $"{typeName}<{format}{(image ? ", access::read_write" : "")}>"; } } }