From 6da40db9dbfabb5583206f17ee1beb52ae09fa61 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Fri, 21 Jun 2024 13:26:44 +0100 Subject: [PATCH] Change how unsized arrays are indexed --- .../CodeGen/Msl/Declarations.cs | 3 ++- .../CodeGen/Msl/Instructions/InstGenMemory.cs | 10 +--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs index 3877a58292..08da117e73 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs @@ -150,7 +150,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl { string typeName = GetVarTypeName(context, field.Type & ~AggregateType.Array); - context.AppendLine($"{typeName} {field.Name};"); + // Probably UB, but this is the approach that MVK takes + context.AppendLine($"{typeName} {field.Name}[1];"); } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs index 135cd80e09..bb1a699399 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs @@ -47,15 +47,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions StructureField field = buffer.Type.Fields[fieldIndex.Value]; varName = buffer.Name; - if ((field.Type & AggregateType.Array) != 0 && field.ArrayLength == 0) - { - // Unsized array, the buffer is indexed instead of the field - fieldName = "." + field.Name; - } - else - { - varName += "->" + field.Name; - } + varName += "->" + field.Name; varType = field.Type; break;