Fix Non-Float Textures + Image Read + FSI Buffers

Fixes Mario Party Superstars
This commit is contained in:
Isaac Marovitz 2024-08-01 14:23:56 +01:00 committed by Isaac Marovitz
parent d5e19a70bd
commit c77f3b90a9
3 changed files with 13 additions and 7 deletions

View file

@ -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}>";

View file

@ -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)

View file

@ -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}<float{(image ? ", access::read_write" : "")}>";
var format = aggregateType switch
{
AggregateType.S32 => "int",
AggregateType.U32 => "uint",
_ => "float"
};
return $"{typeName}<{format}{(image ? ", access::read_write" : "")}>";
}
}
}