Fix support buffer declaration

This commit is contained in:
Isaac Marovitz 2024-06-21 16:01:22 +01:00
commit d17472f2ec
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1

View file

@ -140,19 +140,23 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
foreach (StructureField field in buffer.Type.Fields) foreach (StructureField field in buffer.Type.Fields)
{ {
if (field.Type.HasFlag(AggregateType.Array) && field.ArrayLength > 0) string typeName = GetVarTypeName(context, field.Type & ~AggregateType.Array);
{ string arraySuffix = "";
string typeName = GetVarTypeName(context, field.Type & ~AggregateType.Array);
context.AppendLine($"{typeName} {field.Name}[{field.ArrayLength}];"); if (field.Type.HasFlag(AggregateType.Array))
}
else
{ {
string typeName = GetVarTypeName(context, field.Type & ~AggregateType.Array); if (field.ArrayLength > 0)
{
// Probably UB, but this is the approach that MVK takes arraySuffix = $"[{field.ArrayLength}]";
context.AppendLine($"{typeName} {field.Name}[1];"); }
else
{
// Probably UB, but this is the approach that MVK takes
arraySuffix = "[1]";
}
} }
context.AppendLine($"{typeName} {field.Name}{arraySuffix};");
} }
context.LeaveScope(";"); context.LeaveScope(";");