diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 076d4351c..eec57b83d 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -880,12 +880,10 @@ namespace Ryujinx.Graphics.Vulkan public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) { - DynamicState.SetDepthBias(factor, units, clamp, (enables != 0)); + bool enable = enables != 0; + DynamicState.SetDepthBias(factor, units, clamp, enable); - if (!_supportExtDynamic2) - { - _newState.DepthBiasEnable = enables != 0; - } + _newState.DepthBiasEnable = enable; SignalStateChange(); } @@ -919,11 +917,12 @@ namespace Ryujinx.Graphics.Vulkan } else { - _newState.DepthTestEnable = depthTest.TestEnable; _newState.DepthWriteEnable = depthTest.WriteEnable; _newState.DepthCompareOp = depthTest.Func.Convert(); } + _newState.DepthTestEnable = depthTest.TestEnable; + SignalStateChange(); } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs index e873e1d5e..d44c3f708 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs @@ -434,7 +434,10 @@ namespace Ryujinx.Graphics.Vulkan { api.CmdSetDepthTestEnable(commandBuffer, DepthTestEnable); - api.CmdSetDepthWriteEnable(commandBuffer, DepthWriteEnable); + if (DepthTestEnable) + { + api.CmdSetDepthWriteEnable(commandBuffer, DepthWriteEnable); + } } private readonly void RecordDepthTestCompareOp(ExtExtendedDynamicState api, CommandBuffer commandBuffer) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index e210bebd7..bf2be65ca 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -526,7 +526,10 @@ namespace Ryujinx.Graphics.Vulkan depthStencilState.Back = stencilBack; depthStencilState.StencilTestEnable = StencilTestEnable; depthStencilState.DepthTestEnable = DepthTestEnable; - depthStencilState.DepthWriteEnable = DepthWriteEnable; + if (DepthTestEnable) + { + depthStencilState.DepthWriteEnable = DepthWriteEnable; + } depthStencilState.DepthCompareOp = DepthCompareOp; } @@ -579,7 +582,7 @@ namespace Ryujinx.Graphics.Vulkan colorBlendState.PNext = &colorBlendAdvancedState; } - int baseDynamicStatesCount = 7; + int baseDynamicStatesCount = 6; int additionalDynamicStatesCount = 0; if (!isMoltenVk) @@ -587,9 +590,19 @@ namespace Ryujinx.Graphics.Vulkan baseDynamicStatesCount++; } + if (DepthBiasEnable) + { + baseDynamicStatesCount++; + } + if (supportsExtDynamicState) { - additionalDynamicStatesCount += isMoltenVk ? 8 : 9; + additionalDynamicStatesCount += isMoltenVk ? 7 : 8; + + if (DepthTestEnable) + { + additionalDynamicStatesCount++; + } } if (supportsExtDynamicState2) @@ -610,13 +623,16 @@ namespace Ryujinx.Graphics.Vulkan dynamicStates[0] = DynamicState.Viewport; dynamicStates[1] = DynamicState.Scissor; - dynamicStates[2] = DynamicState.DepthBias; - dynamicStates[3] = DynamicState.StencilCompareMask; - dynamicStates[4] = DynamicState.StencilWriteMask; - dynamicStates[5] = DynamicState.StencilReference; - dynamicStates[6] = DynamicState.BlendConstants; + dynamicStates[2] = DynamicState.StencilCompareMask; + dynamicStates[3] = DynamicState.StencilWriteMask; + dynamicStates[4] = DynamicState.StencilReference; + dynamicStates[5] = DynamicState.BlendConstants; - int currentIndex = 7; + if (DepthBiasEnable) + { + dynamicStates[6] = DynamicState.DepthBias; + } + int currentIndex = DepthBiasEnable ? 7 : 6; if (!isMoltenVk) { @@ -636,7 +652,12 @@ namespace Ryujinx.Graphics.Vulkan dynamicStates[currentIndex++] = DynamicState.CullModeExt; dynamicStates[currentIndex++] = DynamicState.FrontFaceExt; dynamicStates[currentIndex++] = DynamicState.DepthTestEnableExt; - dynamicStates[currentIndex++] = DynamicState.DepthWriteEnableExt; + + if (DepthTestEnable) + { + dynamicStates[currentIndex++] = DynamicState.DepthWriteEnableExt; + } + dynamicStates[currentIndex++] = DynamicState.DepthCompareOpExt; dynamicStates[currentIndex++] = DynamicState.StencilTestEnableExt; dynamicStates[currentIndex++] = DynamicState.StencilOpExt;