diff --git a/src/Ryujinx.Graphics.GAL/ProgramPipelineState.cs b/src/Ryujinx.Graphics.GAL/ProgramPipelineState.cs index 41afb34b0..96fd667ad 100644 --- a/src/Ryujinx.Graphics.GAL/ProgramPipelineState.cs +++ b/src/Ryujinx.Graphics.GAL/ProgramPipelineState.cs @@ -63,6 +63,8 @@ namespace Ryujinx.Graphics.GAL public bool PrimitiveRestartEnable; public uint PatchControlPoints; + public DepthMode DepthMode; + public void SetVertexAttribs(ReadOnlySpan vertexAttribs) { VertexAttribCount = vertexAttribs.Length; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index 4feb8bafc..5fa4702b8 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -771,7 +771,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateDepthMode() { - _context.Renderer.Pipeline.SetDepthMode(GetDepthMode()); + DepthMode mode = GetDepthMode(); + + _pipeline.DepthMode = mode; + + _context.Renderer.Pipeline.SetDepthMode(mode); } /// diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs index b2c4fccdb..9b0c8b9b9 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs @@ -736,6 +736,19 @@ namespace Ryujinx.Graphics.Gpu.Shader return MatchesTexture(specializationState, descriptor); } + /// + /// Populates pipeline state that doesn't exist in older caches with default values + /// based on specialization state. + /// + /// Pipeline state to prepare + private void PreparePipelineState(ref ProgramPipelineState pipelineState) + { + if (!_compute) + { + pipelineState.DepthMode = GraphicsState.DepthMode ? DepthMode.MinusOneToOne : DepthMode.ZeroToOne; + } + } + /// /// Reads shader specialization state that has been serialized. /// @@ -776,6 +789,8 @@ namespace Ryujinx.Graphics.Gpu.Shader { ProgramPipelineState pipelineState = default; dataReader.ReadWithMagicAndSize(ref pipelineState, PgpsMagic); + + specState.PreparePipelineState(ref pipelineState); specState.PipelineState = pipelineState; } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index 79179ce07..a52b44622 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -165,6 +165,7 @@ namespace Ryujinx.Graphics.Vulkan pipeline.DepthTestEnable = state.DepthTest.TestEnable; pipeline.DepthWriteEnable = state.DepthTest.WriteEnable; pipeline.DepthCompareOp = state.DepthTest.Func.Convert(); + pipeline.DepthMode = state.DepthMode == DepthMode.MinusOneToOne; pipeline.FrontFace = state.FrontFace.Convert();