From d512ce122cb1c9a7fe7cb40d3f85d642ee37f897 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 18 Oct 2021 18:38:04 -0300 Subject: Initial tessellation shader support (#2534) * Initial tessellation shader support * Nits * Re-arrange built-in table * This is not needed anymore * PR feedback --- .../Multithreading/CommandHelper.cs | 4 ++++ Ryujinx.Graphics.GAL/Multithreading/CommandType.cs | 2 ++ .../Commands/SetPatchParametersCommand.cs | 25 ++++++++++++++++++++++ .../Commands/SetPolygonModeCommand.cs | 20 +++++++++++++++++ .../Multithreading/ThreadedPipeline.cs | 12 +++++++++++ 5 files changed, 63 insertions(+) create mode 100644 Ryujinx.Graphics.GAL/Multithreading/Commands/SetPatchParametersCommand.cs create mode 100644 Ryujinx.Graphics.GAL/Multithreading/Commands/SetPolygonModeCommand.cs (limited to 'Ryujinx.Graphics.GAL/Multithreading') diff --git a/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs b/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs index 82a75ea7..47ceeb7d 100644 --- a/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs +++ b/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs @@ -181,8 +181,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading SetLineParametersCommand.Run(ref GetCommand(memory), threaded, renderer); _lookup[(int)CommandType.SetLogicOpState] = (Span memory, ThreadedRenderer threaded, IRenderer renderer) => SetLogicOpStateCommand.Run(ref GetCommand(memory), threaded, renderer); + _lookup[(int)CommandType.SetPatchParameters] = (Span memory, ThreadedRenderer threaded, IRenderer renderer) => + SetPatchParametersCommand.Run(ref GetCommand(memory), threaded, renderer); _lookup[(int)CommandType.SetPointParameters] = (Span memory, ThreadedRenderer threaded, IRenderer renderer) => SetPointParametersCommand.Run(ref GetCommand(memory), threaded, renderer); + _lookup[(int)CommandType.SetPolygonMode] = (Span memory, ThreadedRenderer threaded, IRenderer renderer) => + SetPolygonModeCommand.Run(ref GetCommand(memory), threaded, renderer); _lookup[(int)CommandType.SetPrimitiveRestart] = (Span memory, ThreadedRenderer threaded, IRenderer renderer) => SetPrimitiveRestartCommand.Run(ref GetCommand(memory), threaded, renderer); _lookup[(int)CommandType.SetPrimitiveTopology] = (Span memory, ThreadedRenderer threaded, IRenderer renderer) => diff --git a/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs b/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs index 0761a7f0..ac73a3fe 100644 --- a/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs +++ b/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs @@ -72,7 +72,9 @@ SetIndexBuffer, SetLineParameters, SetLogicOpState, + SetPatchParameters, SetPointParameters, + SetPolygonMode, SetPrimitiveRestart, SetPrimitiveTopology, SetProgram, diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetPatchParametersCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetPatchParametersCommand.cs new file mode 100644 index 00000000..7847e8d0 --- /dev/null +++ b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetPatchParametersCommand.cs @@ -0,0 +1,25 @@ +using Ryujinx.Common.Memory; +using System; + +namespace Ryujinx.Graphics.GAL.Multithreading.Commands +{ + struct SetPatchParametersCommand : IGALCommand + { + public CommandType CommandType => CommandType.SetPatchParameters; + private int _vertices; + private Array4 _defaultOuterLevel; + private Array2 _defaultInnerLevel; + + public void Set(int vertices, ReadOnlySpan defaultOuterLevel, ReadOnlySpan defaultInnerLevel) + { + _vertices = vertices; + defaultOuterLevel.CopyTo(_defaultOuterLevel.ToSpan()); + defaultInnerLevel.CopyTo(_defaultInnerLevel.ToSpan()); + } + + public static void Run(ref SetPatchParametersCommand command, ThreadedRenderer threaded, IRenderer renderer) + { + renderer.Pipeline.SetPatchParameters(command._vertices, command._defaultOuterLevel.ToSpan(), command._defaultInnerLevel.ToSpan()); + } + } +} diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetPolygonModeCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetPolygonModeCommand.cs new file mode 100644 index 00000000..6de78f04 --- /dev/null +++ b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetPolygonModeCommand.cs @@ -0,0 +1,20 @@ +namespace Ryujinx.Graphics.GAL.Multithreading.Commands +{ + struct SetPolygonModeCommand : IGALCommand + { + public CommandType CommandType => CommandType.SetPolygonMode; + private PolygonMode _frontMode; + private PolygonMode _backMode; + + public void Set(PolygonMode frontMode, PolygonMode backMode) + { + _frontMode = frontMode; + _backMode = backMode; + } + + public static void Run(ref SetPolygonModeCommand command, ThreadedRenderer threaded, IRenderer renderer) + { + renderer.Pipeline.SetPolygonMode(command._frontMode, command._backMode); + } + } +} diff --git a/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs b/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs index 0f523481..3c39a77f 100644 --- a/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs +++ b/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs @@ -179,12 +179,24 @@ namespace Ryujinx.Graphics.GAL.Multithreading _renderer.QueueCommand(); } + public void SetPatchParameters(int vertices, ReadOnlySpan defaultOuterLevel, ReadOnlySpan defaultInnerLevel) + { + _renderer.New().Set(vertices, defaultOuterLevel, defaultInnerLevel); + _renderer.QueueCommand(); + } + public void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin) { _renderer.New().Set(size, isProgramPointSize, enablePointSprite, origin); _renderer.QueueCommand(); } + public void SetPolygonMode(PolygonMode frontMode, PolygonMode backMode) + { + _renderer.New().Set(frontMode, backMode); + _renderer.QueueCommand(); + } + public void SetPrimitiveRestart(bool enable, int index) { _renderer.New().Set(enable, index); -- cgit v1.2.3