From a7a49cc8fe2d73d1af878cdb9ad7022a9e270ba1 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Sat, 20 Jul 2024 19:07:19 -0700 Subject: [PATCH] Revert some changes that were out of scope/intent of commit --- src/Ryujinx.Graphics.GAL/IPipeline.cs | 3 +- .../Multithreading/CommandHelper.cs | 1 - .../Multithreading/CommandType.cs | 1 - .../Commands/SetDepthBiasCommand.cs | 6 ++-- .../Commands/SetDepthBiasEnableCommand.cs | 19 ---------- .../Multithreading/ThreadedPipeline.cs | 10 ++---- .../Engine/Threed/StateUpdater.cs | 9 ++--- src/Ryujinx.Graphics.OpenGL/Pipeline.cs | 30 ++++++---------- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 35 ++++++++----------- 9 files changed, 35 insertions(+), 79 deletions(-) delete mode 100644 src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasEnableCommand.cs diff --git a/src/Ryujinx.Graphics.GAL/IPipeline.cs b/src/Ryujinx.Graphics.GAL/IPipeline.cs index 71f99fc0b..cbf1bc3a2 100644 --- a/src/Ryujinx.Graphics.GAL/IPipeline.cs +++ b/src/Ryujinx.Graphics.GAL/IPipeline.cs @@ -47,8 +47,7 @@ namespace Ryujinx.Graphics.GAL void SetBlendState(AdvancedBlendDescriptor blend); void SetBlendState(int index, BlendDescriptor blend); - void SetDepthBias(float factor, float units, float clamp); - void SetDepthBiasEnable(PolygonModeMask enables); + void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp); void SetDepthClamp(bool clamp); void SetDepthMode(DepthMode mode); void SetDepthTest(DepthTestDescriptor depthTest); diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs b/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs index 67eccb34c..ef227d4a5 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs @@ -116,7 +116,6 @@ namespace Ryujinx.Graphics.GAL.Multithreading Register(CommandType.SetBlendStateAdvanced); Register(CommandType.SetBlendState); Register(CommandType.SetDepthBias); - Register(CommandType.SetDepthBiasEnable); Register(CommandType.SetDepthClamp); Register(CommandType.SetDepthMode); Register(CommandType.SetDepthTest); diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs b/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs index cb009c75d..cf3f5d6c1 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs @@ -76,7 +76,6 @@ namespace Ryujinx.Graphics.GAL.Multithreading SetBlendStateAdvanced, SetBlendState, SetDepthBias, - SetDepthBiasEnable, SetDepthClamp, SetDepthMode, SetDepthTest, diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasCommand.cs index 1fa380327..0c46fbda2 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasCommand.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasCommand.cs @@ -3,12 +3,14 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands struct SetDepthBiasCommand : IGALCommand, IGALCommand { public readonly CommandType CommandType => CommandType.SetDepthBias; + private PolygonModeMask _enables; private float _factor; private float _units; private float _clamp; - public void Set(float factor, float units, float clamp) + public void Set(PolygonModeMask enables, float factor, float units, float clamp) { + _enables = enables; _factor = factor; _units = units; _clamp = clamp; @@ -16,7 +18,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands public static void Run(ref SetDepthBiasCommand command, ThreadedRenderer threaded, IRenderer renderer) { - renderer.Pipeline.SetDepthBias(command._factor, command._units, command._clamp); + renderer.Pipeline.SetDepthBias(command._enables, command._factor, command._units, command._clamp); } } } diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasEnableCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasEnableCommand.cs deleted file mode 100644 index 176da6f39..000000000 --- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetDepthBiasEnableCommand.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ryujinx.Graphics.GAL.Multithreading.Commands -{ - struct SetDepthBiasEnableCommand : IGALCommand, IGALCommand - { - public readonly CommandType CommandType => CommandType.SetDepthBias; - private PolygonModeMask _enables; - - - public void Set(PolygonModeMask enables) - { - _enables = enables; - } - - public static void Run(ref SetDepthBiasEnableCommand command, ThreadedRenderer threaded, IRenderer renderer) - { - renderer.Pipeline.SetDepthBiasEnable(command._enables); - } - } -} diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs index 45ae679ce..edd79d8a0 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs @@ -141,15 +141,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading _renderer.QueueCommand(); } - public void SetDepthBias(float factor, float units, float clamp) + public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) { - _renderer.New().Set(factor, units, clamp); - _renderer.QueueCommand(); - } - - public void SetDepthBiasEnable(PolygonModeMask enables) - { - _renderer.New().Set(enables); + _renderer.New().Set(enables, factor, units, clamp); _renderer.QueueCommand(); } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index c4388fe96..1cdb09895 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -850,7 +850,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { _pipeline.BiasEnable = 0; - _context.Renderer.Pipeline.SetDepthBiasEnable(0); + _context.Renderer.Pipeline.SetDepthBias(0, 0, 0, 0); return; } @@ -872,12 +872,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed _pipeline.BiasEnable = enables; - _context.Renderer.Pipeline.SetDepthBiasEnable(enables); - - if (enables > 0) - { - _context.Renderer.Pipeline.SetDepthBias(factor, units / 2f, clamp); - } + _context.Renderer.Pipeline.SetDepthBias(enables, factor, units / 2f, clamp); } /// diff --git a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs index fb277f94a..f04cdd762 100644 --- a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -831,9 +831,9 @@ namespace Ryujinx.Graphics.OpenGL GL.Enable(IndexedEnableCap.Blend, index); } - public void SetDepthBias(float factor, float units, float clamp) + public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) { - if (factor == 0 && units == 0) + if (enables == 0 || (factor == 0 && units == 0)) { GL.Disable(EnableCap.PolygonOffsetPoint); GL.Disable(EnableCap.PolygonOffsetLine); @@ -842,23 +842,6 @@ namespace Ryujinx.Graphics.OpenGL return; } - if (HwCapabilities.SupportsPolygonOffsetClamp) - { - GL.PolygonOffsetClamp(factor, units, clamp); - } - else - { - GL.PolygonOffset(factor, units); - } - } - - public void SetDepthBiasEnable(PolygonModeMask enables) - { - if (enables == 0) - { - return; - } - if ((enables & PolygonModeMask.Point) != 0) { GL.Enable(EnableCap.PolygonOffsetPoint); @@ -885,6 +868,15 @@ namespace Ryujinx.Graphics.OpenGL { GL.Disable(EnableCap.PolygonOffsetFill); } + + if (HwCapabilities.SupportsPolygonOffsetClamp) + { + GL.PolygonOffsetClamp(factor, units, clamp); + } + else + { + GL.PolygonOffset(factor, units); + } } public void SetDepthClamp(bool clamp) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 04d877a0c..a25f7faf3 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -785,37 +785,32 @@ namespace Ryujinx.Graphics.Vulkan SignalStateChange(); } - public void SetDepthBias(float factor, float units, float clamp) + public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) { - if (factor == 0 && units == 0 && _newState.DepthBiasEnable) - { - _newState.DepthBiasEnable = false; + bool depthBiasEnable = (enables != 0) && (factor != 0 && units != 0); + bool changed = false; - SignalStateChange(); - - return; - } - else if (factor == 0 && units == 0 && !_newState.DepthBiasEnable) + if (factor == 0 && units == 0 && !_newState.DepthBiasEnable) { return; } - DynamicState.SetDepthBias(factor, units, clamp); - - SignalStateChange(); - } - - public void SetDepthBiasEnable(PolygonModeMask enables) - { - bool depthBiasEnable = enables != 0; - if (_newState.DepthBiasEnable != depthBiasEnable) { _newState.DepthBiasEnable = depthBiasEnable; - - SignalStateChange(); + changed = true; } + if (depthBiasEnable) + { + DynamicState.SetDepthBias(factor, units, clamp); + changed = true; + } + + if (changed) + { + SignalStateChange(); + } } public void SetDepthClamp(bool clamp)