From 262452f586da9879f232ae6ac7ba12290974cd2c Mon Sep 17 00:00:00 2001 From: Samuliak Date: Thu, 16 May 2024 16:06:35 +0200 Subject: [PATCH] offset storage buffer bindings by 15 --- src/Ryujinx.Graphics.Metal/Pipeline.cs | 3 ++- src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index dd2e3bf99..33d5678a4 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -600,11 +600,12 @@ namespace Ryujinx.Graphics.Metal { if (buffer.Range.Size != 0) { + // Offset the binding by 15 _storageBuffers.Add(new BufferInfo { Handle = buffer.Range.Handle.ToIntPtr(), Offset = buffer.Range.Offset, - Index = buffer.Binding + Index = buffer.Binding + 15 }); } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs index 745723f6d..3b515eb84 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs @@ -129,7 +129,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl foreach (var storageBuffers in context.Properties.StorageBuffers.Values) { var varType = storageBuffers.Type.Fields[0].Type & ~AggregateType.Array; - args = args.Append($"device {Declarations.GetVarTypeName(context, varType)} *{storageBuffers.Name} [[buffer({storageBuffers.Binding})]]").ToArray(); + // Offset the binding by 15 to avoid clashing with the constant buffers + args = args.Append($"device {Declarations.GetVarTypeName(context, varType)} *{storageBuffers.Name} [[buffer({15 + storageBuffers.Binding})]]").ToArray(); } foreach (var texture in context.Properties.Textures.Values)