From 131ab75d5570c67715f9973e4996a4764cf9a61d Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Tue, 28 May 2024 02:18:59 -0400 Subject: [PATCH] Handle stride 0 on regular buffers --- .../EncoderStateManager.cs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs index f440a9a60..f6906d6f3 100644 --- a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs +++ b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs @@ -739,17 +739,34 @@ namespace Ryujinx.Graphics.Metal for (int i = 0; i < bufferDescriptors.Length; i++) { var layout = vertexDescriptor.Layouts.Object((ulong)i); - layout.Stride = (indexMask & (1u << i)) != 0 ? (ulong)bufferDescriptors[i].Stride : 0; - if (bufferDescriptors[i].Divisor > 0) + if ((indexMask & (1u << i)) != 0) { - layout.StepFunction = MTLVertexStepFunction.PerInstance; - layout.StepRate = (ulong)bufferDescriptors[i].Divisor; + layout.Stride = (ulong)bufferDescriptors[i].Stride; + + if (layout.Stride == 0) + { + layout.Stride = 1; + layout.StepFunction = MTLVertexStepFunction.Constant; + layout.StepRate = 0; + } + else + { + if (bufferDescriptors[i].Divisor > 0) + { + layout.StepFunction = MTLVertexStepFunction.PerInstance; + layout.StepRate = (ulong)bufferDescriptors[i].Divisor; + } + else + { + layout.StepFunction = MTLVertexStepFunction.PerVertex; + layout.StepRate = 1; + } + } } else { - layout.StepFunction = MTLVertexStepFunction.PerVertex; - layout.StepRate = 1; + layout.Stride = 0; } }