From 48ad342ee94b46caedcfaf7f3b8a6b0a28a3533c Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Sun, 21 Jul 2024 14:22:15 -0700 Subject: [PATCH] Resolve two validation errors that were created by changes 1. One stating that the bound pipeline is identical to the previous with a dynamic state that was previously static (DepthBias) which might cause issues in non Vulkan SDK 1.3 conformant drivers. 2. DynamicState command is sent without current pipeline having the dynamic state enabled. --- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 12 +++++------- src/Ryujinx.Graphics.Vulkan/PipelineState.cs | 17 +++-------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 275ec9228..795a1f2ea 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -793,24 +793,22 @@ namespace Ryujinx.Graphics.Vulkan } bool depthBiasEnable = (enables != PolygonModeMask.None) && (factor != 0 && units != 0); - bool changed = false; if (_newState.DepthBiasEnable != depthBiasEnable) { _newState.DepthBiasEnable = depthBiasEnable; - changed = true; } if (depthBiasEnable) { DynamicState.SetDepthBias(factor, units, clamp); - changed = true; + } + else + { + DynamicState.SetDepthBias(0, 0, 0); } - if (changed) - { - SignalStateChange(); - } + SignalStateChange(); } public void SetDepthClamp(bool clamp) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index cfb7ef361..12c0e2bee 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -565,12 +565,7 @@ namespace Ryujinx.Graphics.Vulkan bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState; - int dynamicStatesCount = supportsExtDynamicState ? 7 : 6; - - if (DepthBiasEnable) - { - dynamicStatesCount++; - } + int dynamicStatesCount = supportsExtDynamicState ? 8 : 7; DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount]; @@ -580,17 +575,11 @@ namespace Ryujinx.Graphics.Vulkan dynamicStates[3] = DynamicState.StencilWriteMask; dynamicStates[4] = DynamicState.StencilReference; dynamicStates[5] = DynamicState.BlendConstants; - - dynamicStatesCount = 6; - - if (DepthBiasEnable) - { - dynamicStates[dynamicStatesCount++] = DynamicState.DepthBias; - } + dynamicStates[6] = DynamicState.DepthBias; if (supportsExtDynamicState) { - dynamicStates[dynamicStatesCount++] = DynamicState.VertexInputBindingStrideExt; + dynamicStates[7] = DynamicState.VertexInputBindingStrideExt; } var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo