From 14c58f62eb11d66e16e4fa0be66f7b5afd3869d9 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Sat, 18 May 2024 22:27:18 -0400 Subject: [PATCH] Be smart and use a bitmask not a list --- src/Ryujinx.Graphics.Metal/EncoderStateManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs index 6b8689877..e13b3cde6 100644 --- a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs +++ b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs @@ -564,8 +564,7 @@ namespace Ryujinx.Graphics.Metal private static MTLVertexDescriptor BuildVertexDescriptor(VertexBufferDescriptor[] bufferDescriptors, VertexAttribDescriptor[] attribDescriptors) { var vertexDescriptor = new MTLVertexDescriptor(); - - var usedIndexes = new List(); + uint indexMask = 0; // TODO: Handle 'zero' buffers for (int i = 0; i < attribDescriptors.Length; i++) @@ -573,7 +572,7 @@ namespace Ryujinx.Graphics.Metal var attrib = vertexDescriptor.Attributes.Object((ulong)i); // TODO: Format should not be hardcoded attrib.Format = MTLVertexFormat.Float4; - usedIndexes.Add(attribDescriptors[i].BufferIndex); + indexMask |= 1u << attribDescriptors[i].BufferIndex; attrib.BufferIndex = (ulong)attribDescriptors[i].BufferIndex; attrib.Offset = (ulong)attribDescriptors[i].Offset; } @@ -581,7 +580,7 @@ namespace Ryujinx.Graphics.Metal for (int i = 0; i < bufferDescriptors.Length; i++) { var layout = vertexDescriptor.Layouts.Object((ulong)i); - layout.Stride = usedIndexes.Contains(i) ? (ulong)bufferDescriptors[i].Stride : 0; + layout.Stride = (indexMask & (1u << i)) != 0 ? (ulong)bufferDescriptors[i].Stride : 0; } return vertexDescriptor;