From 2fd093d4b478097099d899919ec01f0afdc917f9 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Mon, 9 Sep 2024 21:17:44 -0700 Subject: [PATCH] Avoid setting stride if dynamic state is supported --- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 4 ++-- src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs | 4 ++-- src/Ryujinx.Graphics.Vulkan/PipelineState.cs | 4 ++-- src/Ryujinx.Graphics.Vulkan/VertexBufferState.cs | 12 +++++++++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 0343bac6e3..5eb2fc5594 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -1378,7 +1378,7 @@ namespace Ryujinx.Graphics.Vulkan { int count = Math.Min(Constants.MaxVertexBuffers, vertexBuffers.Length); - _newState.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, 0, VertexInputRate.Vertex); + _newState.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, _supportExtDynamic && (!Gd.IsMoltenVk || Gd.SupportsMTL31) ? null : 0, VertexInputRate.Vertex); int validCount = 1; @@ -1407,7 +1407,7 @@ namespace Ryujinx.Graphics.Vulkan _newState.Internal.VertexBindingDescriptions[descriptorIndex] = new VertexInputBindingDescription( (uint)binding, - (uint)vertexBuffer.Stride, + _supportExtDynamic && (!Gd.IsMoltenVk || Gd.SupportsMTL31) ? null : (uint)vertexBuffer.Stride, inputRate); int vbSize = vertexBuffer.Buffer.Size; diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index c6b317afc5..ecfa1d839b 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -256,7 +256,7 @@ namespace Ryujinx.Graphics.Vulkan } int descriptorIndex = 1; - pipeline.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, 0, VertexInputRate.Vertex); + pipeline.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, extendedDynamicState && (!gd.IsMoltenVk || gd.SupportsMTL31) ? null : 0, VertexInputRate.Vertex); for (int i = 0; i < vbCount; i++) { @@ -276,7 +276,7 @@ namespace Ryujinx.Graphics.Vulkan // TODO: Support divisor > 1 pipeline.Internal.VertexBindingDescriptions[descriptorIndex++] = new VertexInputBindingDescription( (uint)i + 1, - (uint)alignedStride, + extendedDynamicState && (!gd.IsMoltenVk || gd.SupportsMTL31) ? null : (uint)alignedStride, inputRate); } } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index d1630faf34..11c748cf43 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -466,7 +466,7 @@ namespace Ryujinx.Graphics.Vulkan bool isMoltenVk = gd.IsMoltenVk; - if (isMoltenVk) + if (isMoltenVk && !_supportsExtDynamicState) { UpdateVertexAttributeDescriptions(gd); } @@ -480,7 +480,7 @@ namespace Ryujinx.Graphics.Vulkan { SType = StructureType.PipelineVertexInputStateCreateInfo, VertexAttributeDescriptionCount = VertexAttributeDescriptionsCount, - PVertexAttributeDescriptions = isMoltenVk ? pVertexAttributeDescriptions2 : pVertexAttributeDescriptions, + PVertexAttributeDescriptions = isMoltenVk && !_supportsExtDynamicState ? pVertexAttributeDescriptions2 : pVertexAttributeDescriptions, VertexBindingDescriptionCount = VertexBindingDescriptionsCount, PVertexBindingDescriptions = pVertexBindingDescriptions, }; diff --git a/src/Ryujinx.Graphics.Vulkan/VertexBufferState.cs b/src/Ryujinx.Graphics.Vulkan/VertexBufferState.cs index 6f27bb68b9..9d56e316a6 100644 --- a/src/Ryujinx.Graphics.Vulkan/VertexBufferState.cs +++ b/src/Ryujinx.Graphics.Vulkan/VertexBufferState.cs @@ -71,7 +71,10 @@ namespace Ryujinx.Graphics.Vulkan _buffer = autoBuffer; - state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)stride; + if (!gd.Capabilities.SupportsExtendedDynamicState) + { + state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)stride; + } } return; @@ -79,8 +82,11 @@ namespace Ryujinx.Graphics.Vulkan autoBuffer = gd.BufferManager.GetBuffer(cbs.CommandBuffer, _handle, false, out int size); - // The original stride must be reapplied in case it was rewritten. - state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)_stride; + if (!gd.Capabilities.SupportsExtendedDynamicState) + { + // The original stride must be reapplied in case it was rewritten. + state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)_stride; + } if (_offset >= size) {