From 506f25054df719d11043bb7ae9c71fbbdd80aa03 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Thu, 16 May 2024 19:09:40 -0700 Subject: [PATCH] LineWidth is not supported on MoltenVK --- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 9 ++++--- .../PipelineDynamicState.cs | 24 +++++++++++++++---- src/Ryujinx.Graphics.Vulkan/PipelineState.cs | 14 ++++++++--- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 301718974b..6881ba9110 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -971,8 +971,11 @@ namespace Ryujinx.Graphics.Vulkan public void SetLineParameters(float width, bool smooth) { - DynamicState.SetLineWidth(Gd.Capabilities.SupportsWideLines ? width : 1.0f); - + if (!Gd.IsMoltenVk) + { + DynamicState.SetLineWidth(Gd.Capabilities.SupportsWideLines ? width : 1.0f); + } + SignalStateChange(); } @@ -1506,7 +1509,7 @@ namespace Ryujinx.Graphics.Vulkan _vertexBuffersDirty = ulong.MaxValue >> (64 - _vertexBuffers.Length); _descriptorSetUpdater.SignalCommandBufferChange(); - DynamicState.ForceAllDirty(); + DynamicState.ForceAllDirty(Gd); _currentPipelineHandle = 0; } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs index b5af582da1..9ec4bbb59b 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs @@ -63,8 +63,9 @@ namespace Ryujinx.Graphics.Vulkan DepthTestCompareOp = 1 << 8, StencilTestEnable = 1 << 9, Toplogy = 1 << 10, - LineWidth = 1 <<11, - All = Blend | DepthBias | Scissor | Stencil | Viewport | CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable | Toplogy | LineWidth, + LineWidth = 1 << 11, + Standard = Blend | DepthBias | Scissor | Stencil | Viewport | LineWidth, + Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable | Toplogy, } private DirtyFlags _dirty; @@ -204,9 +205,19 @@ namespace Ryujinx.Graphics.Vulkan _dirty |= DirtyFlags.LineWidth; } - public void ForceAllDirty() + public void ForceAllDirty(VulkanRenderer gd) { - _dirty = DirtyFlags.All; + _dirty = DirtyFlags.Standard; + + if (gd.Capabilities.SupportsExtendedDynamicState) + { + _dirty = DirtyFlags.Standard | DirtyFlags.Extended; + } + + if (gd.IsMoltenVk) + { + _dirty &= ~DirtyFlags.LineWidth; + } } public void ReplayIfDirty(Vk api, CommandBuffer commandBuffer) @@ -351,7 +362,10 @@ namespace Ryujinx.Graphics.Vulkan private void RecordLineWidth(Vk api, CommandBuffer commandBuffer) { - api.CmdSetLineWidth(commandBuffer, _linewidth); + if (!OperatingSystem.IsMacOS()) + { + api.CmdSetLineWidth(commandBuffer, _linewidth); + } } } } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index ddfd39070d..212062c695 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -482,6 +482,11 @@ namespace Ryujinx.Graphics.Vulkan DepthBiasEnable = DepthBiasEnable, }; + if (isMoltenVk) + { + rasterizationState.LineWidth = 1.0f; + } + if (!supportsExtDynamicState) { rasterizationState.CullMode = CullMode; @@ -603,7 +608,7 @@ namespace Ryujinx.Graphics.Vulkan colorBlendState.PNext = &colorBlendAdvancedState; } - int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 16 : 17) : 8; + int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 16 : 17) : (isMoltenVk ? 7 : 8); DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount]; @@ -614,8 +619,11 @@ namespace Ryujinx.Graphics.Vulkan dynamicStates[4] = DynamicState.StencilWriteMask; dynamicStates[5] = DynamicState.StencilReference; dynamicStates[6] = DynamicState.BlendConstants; - dynamicStates[7] = DynamicState.LineWidth; - + + if(!isMoltenVk) + { + dynamicStates[7] = DynamicState.LineWidth; + } if (supportsExtDynamicState) {