Просмотр исходного кода

Vulkan: Include DepthMode in ProgramPipelineState (#5185)

riperiperi 2 лет назад
Родитель
Сommit
4741a05df9

+ 2 - 0
src/Ryujinx.Graphics.GAL/ProgramPipelineState.cs

@@ -63,6 +63,8 @@ namespace Ryujinx.Graphics.GAL
         public bool PrimitiveRestartEnable;
         public bool PrimitiveRestartEnable;
         public uint PatchControlPoints;
         public uint PatchControlPoints;
 
 
+        public DepthMode DepthMode;
+
         public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
         public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
         {
         {
             VertexAttribCount = vertexAttribs.Length;
             VertexAttribCount = vertexAttribs.Length;

+ 5 - 1
src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs

@@ -771,7 +771,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
         /// </summary>
         /// </summary>
         private void UpdateDepthMode()
         private void UpdateDepthMode()
         {
         {
-            _context.Renderer.Pipeline.SetDepthMode(GetDepthMode());
+            DepthMode mode = GetDepthMode();
+
+            _pipeline.DepthMode = mode;
+
+            _context.Renderer.Pipeline.SetDepthMode(mode);
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 15 - 0
src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs

@@ -736,6 +736,19 @@ namespace Ryujinx.Graphics.Gpu.Shader
             return MatchesTexture(specializationState, descriptor);
             return MatchesTexture(specializationState, descriptor);
         }
         }
 
 
+        /// <summary>
+        /// Populates pipeline state that doesn't exist in older caches with default values
+        /// based on specialization state.
+        /// </summary>
+        /// <param name="pipelineState">Pipeline state to prepare</param>
+        private void PreparePipelineState(ref ProgramPipelineState pipelineState)
+        {
+            if (!_compute)
+            {
+                pipelineState.DepthMode = GraphicsState.DepthMode ? DepthMode.MinusOneToOne : DepthMode.ZeroToOne;
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// Reads shader specialization state that has been serialized.
         /// Reads shader specialization state that has been serialized.
         /// </summary>
         /// </summary>
@@ -776,6 +789,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
             {
             {
                 ProgramPipelineState pipelineState = default;
                 ProgramPipelineState pipelineState = default;
                 dataReader.ReadWithMagicAndSize(ref pipelineState, PgpsMagic);
                 dataReader.ReadWithMagicAndSize(ref pipelineState, PgpsMagic);
+
+                specState.PreparePipelineState(ref pipelineState);
                 specState.PipelineState = pipelineState;
                 specState.PipelineState = pipelineState;
             }
             }
 
 

+ 1 - 0
src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs

@@ -165,6 +165,7 @@ namespace Ryujinx.Graphics.Vulkan
             pipeline.DepthTestEnable = state.DepthTest.TestEnable;
             pipeline.DepthTestEnable = state.DepthTest.TestEnable;
             pipeline.DepthWriteEnable = state.DepthTest.WriteEnable;
             pipeline.DepthWriteEnable = state.DepthTest.WriteEnable;
             pipeline.DepthCompareOp = state.DepthTest.Func.Convert();
             pipeline.DepthCompareOp = state.DepthTest.Func.Convert();
+            pipeline.DepthMode = state.DepthMode == DepthMode.MinusOneToOne;
 
 
             pipeline.FrontFace = state.FrontFace.Convert();
             pipeline.FrontFace = state.FrontFace.Convert();