diff --git a/src/Ryujinx.Graphics.GAL/PolygonModeMask.cs b/src/Ryujinx.Graphics.GAL/PolygonModeMask.cs index c6ac45099..f9588e4fb 100644 --- a/src/Ryujinx.Graphics.GAL/PolygonModeMask.cs +++ b/src/Ryujinx.Graphics.GAL/PolygonModeMask.cs @@ -5,6 +5,7 @@ namespace Ryujinx.Graphics.GAL [Flags] public enum PolygonModeMask { + None = 0, Point = 1 << 0, Line = 1 << 1, Fill = 1 << 2, diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index 1cdb09895..ffb70c1da 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -841,16 +841,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateDepthBiasState() { - if (_pipeline.BiasEnable == 0 && (_state.State.DepthBiasFactor == 0 && _state.State.DepthBiasUnits == 0)) + if (_state.State.DepthBiasFactor == 0 && _state.State.DepthBiasUnits == 0) { - return; - } - else if (_pipeline.BiasEnable != 0 && - (_state.State.DepthBiasFactor == 0 && _state.State.DepthBiasUnits == 0)) - { - _pipeline.BiasEnable = 0; + if (_pipeline.BiasEnable != PolygonModeMask.None) + { + _pipeline.BiasEnable = PolygonModeMask.None; - _context.Renderer.Pipeline.SetDepthBias(0, 0, 0, 0); + _context.Renderer.Pipeline.SetDepthBias(PolygonModeMask.None, 0, 0, 0); + } return; } @@ -861,7 +859,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed float units = _state.State.DepthBiasUnits; float clamp = _state.State.DepthBiasClamp; - PolygonModeMask enables = 0; + PolygonModeMask enables = PolygonModeMask.None; if (factor != 0 && units != 0) { diff --git a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs index f04cdd762..c86cb95f3 100644 --- a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -833,7 +833,7 @@ namespace Ryujinx.Graphics.OpenGL public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) { - if (enables == 0 || (factor == 0 && units == 0)) + if (enables == PolygonModeMask.None || (factor == 0 && units == 0)) { GL.Disable(EnableCap.PolygonOffsetPoint); GL.Disable(EnableCap.PolygonOffsetLine); diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index a25f7faf3..275ec9228 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -787,14 +787,14 @@ namespace Ryujinx.Graphics.Vulkan public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) { - bool depthBiasEnable = (enables != 0) && (factor != 0 && units != 0); - bool changed = false; - if (factor == 0 && units == 0 && !_newState.DepthBiasEnable) { return; } + bool depthBiasEnable = (enables != PolygonModeMask.None) && (factor != 0 && units != 0); + bool changed = false; + if (_newState.DepthBiasEnable != depthBiasEnable) { _newState.DepthBiasEnable = depthBiasEnable; diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index 8373c9737..cfb7ef361 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -564,7 +564,9 @@ namespace Ryujinx.Graphics.Vulkan } bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState; + int dynamicStatesCount = supportsExtDynamicState ? 7 : 6; + if (DepthBiasEnable) { dynamicStatesCount++; @@ -579,14 +581,16 @@ namespace Ryujinx.Graphics.Vulkan dynamicStates[4] = DynamicState.StencilReference; dynamicStates[5] = DynamicState.BlendConstants; + dynamicStatesCount = 6; + if (DepthBiasEnable) { - dynamicStates[6] = DynamicState.DepthBias; + dynamicStates[dynamicStatesCount++] = DynamicState.DepthBias; } if (supportsExtDynamicState) { - dynamicStates[dynamicStatesCount - 1] = DynamicState.VertexInputBindingStrideExt; + dynamicStates[dynamicStatesCount++] = DynamicState.VertexInputBindingStrideExt; } var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo