Fix support buffer declaration

This commit is contained in:
Isaac Marovitz 2024-06-21 16:01:22 +01:00
parent 075bba2c06
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)
{
if (field.Type.HasFlag(AggregateType.Array) && field.ArrayLength > 0)
{
string typeName = GetVarTypeName(context, field.Type & ~AggregateType.Array);
string typeName = GetVarTypeName(context, field.Type & ~AggregateType.Array);
string arraySuffix = "";
context.AppendLine($"{typeName} {field.Name}[{field.ArrayLength}];");
}
else
if (field.Type.HasFlag(AggregateType.Array))
{
string typeName = GetVarTypeName(context, field.Type & ~AggregateType.Array);
// Probably UB, but this is the approach that MVK takes
context.AppendLine($"{typeName} {field.Name}[1];");
if (field.ArrayLength > 0)
{
arraySuffix = $"[{field.ArrayLength}]";
}
else
{
// Probably UB, but this is the approach that MVK takes
arraySuffix = "[1]";
}
}
context.AppendLine($"{typeName} {field.Name}{arraySuffix};");
}
context.LeaveScope(";");