From b46b63e06a36845175f68331edb5ddeeb34de27b Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 5 Jul 2022 19:58:36 -0300 Subject: Add support for alpha to coverage dithering (#3069) * Add support for alpha to coverage dithering * Shader cache version bump * Fix wrong alpha register * Ensure support buffer is cleared * New shader specialization based approach --- Ryujinx.Graphics.GAL/IPipeline.cs | 2 ++ Ryujinx.Graphics.GAL/MultisampleDescriptor.cs | 19 +++++++++++++++++++ Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs | 2 ++ Ryujinx.Graphics.GAL/Multithreading/CommandType.cs | 1 + .../Commands/SetMultisampleStateCommand.cs | 18 ++++++++++++++++++ .../Multithreading/ThreadedPipeline.cs | 6 ++++++ Ryujinx.Graphics.GAL/SupportBufferUpdater.cs | 1 + 7 files changed, 49 insertions(+) create mode 100644 Ryujinx.Graphics.GAL/MultisampleDescriptor.cs create mode 100644 Ryujinx.Graphics.GAL/Multithreading/Commands/SetMultisampleStateCommand.cs (limited to 'Ryujinx.Graphics.GAL') diff --git a/Ryujinx.Graphics.GAL/IPipeline.cs b/Ryujinx.Graphics.GAL/IPipeline.cs index 83afcaa3..da04362d 100644 --- a/Ryujinx.Graphics.GAL/IPipeline.cs +++ b/Ryujinx.Graphics.GAL/IPipeline.cs @@ -60,6 +60,8 @@ namespace Ryujinx.Graphics.GAL void SetLogicOpState(bool enable, LogicalOp op); + void SetMultisampleState(MultisampleDescriptor multisample); + void SetPatchParameters(int vertices, ReadOnlySpan defaultOuterLevel, ReadOnlySpan defaultInnerLevel); void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin); diff --git a/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs b/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs new file mode 100644 index 00000000..76e56987 --- /dev/null +++ b/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs @@ -0,0 +1,19 @@ +namespace Ryujinx.Graphics.GAL +{ + public struct MultisampleDescriptor + { + public bool AlphaToCoverageEnable { get; } + public bool AlphaToCoverageDitherEnable { get; } + public bool AlphaToOneEnable { get; } + + public MultisampleDescriptor( + bool alphaToCoverageEnable, + bool alphaToCoverageDitherEnable, + bool alphaToOneEnable) + { + AlphaToCoverageEnable = alphaToCoverageEnable; + AlphaToCoverageDitherEnable = alphaToCoverageDitherEnable; + AlphaToOneEnable = alphaToOneEnable; + } + } +} diff --git a/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs b/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs index 442a9045..95b33bc6 100644 --- a/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs +++ b/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs @@ -179,6 +179,8 @@ 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.SetMultisampleState] = (Span memory, ThreadedRenderer threaded, IRenderer renderer) => + SetMultisampleStateCommand.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) => diff --git a/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs b/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs index 5c42abd1..8f0a0095 100644 --- a/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs +++ b/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs @@ -71,6 +71,7 @@ SetIndexBuffer, SetLineParameters, SetLogicOpState, + SetMultisampleState, SetPatchParameters, SetPointParameters, SetPolygonMode, diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetMultisampleStateCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetMultisampleStateCommand.cs new file mode 100644 index 00000000..f981c6ce --- /dev/null +++ b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetMultisampleStateCommand.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.Graphics.GAL.Multithreading.Commands +{ + struct SetMultisampleStateCommand : IGALCommand + { + public CommandType CommandType => CommandType.SetMultisampleState; + private MultisampleDescriptor _multisample; + + public void Set(MultisampleDescriptor multisample) + { + _multisample = multisample; + } + + public static void Run(ref SetMultisampleStateCommand command, ThreadedRenderer threaded, IRenderer renderer) + { + renderer.Pipeline.SetMultisampleState(command._multisample); + } + } +} diff --git a/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs b/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs index 2a1f474a..aebf210d 100644 --- a/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs +++ b/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs @@ -184,6 +184,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading _renderer.QueueCommand(); } + public void SetMultisampleState(MultisampleDescriptor multisample) + { + _renderer.New().Set(multisample); + _renderer.QueueCommand(); + } + public void SetPatchParameters(int vertices, ReadOnlySpan defaultOuterLevel, ReadOnlySpan defaultInnerLevel) { _renderer.New().Set(vertices, defaultOuterLevel, defaultInnerLevel); diff --git a/Ryujinx.Graphics.GAL/SupportBufferUpdater.cs b/Ryujinx.Graphics.GAL/SupportBufferUpdater.cs index da7a2461..5d73b45a 100644 --- a/Ryujinx.Graphics.GAL/SupportBufferUpdater.cs +++ b/Ryujinx.Graphics.GAL/SupportBufferUpdater.cs @@ -18,6 +18,7 @@ namespace Ryujinx.Graphics.GAL { _renderer = renderer; Handle = renderer.CreateBuffer(SupportBuffer.RequiredSize); + renderer.Pipeline.ClearBuffer(Handle, 0, SupportBuffer.RequiredSize, 0); } private void MarkDirty(int startOffset, int byteSize) -- cgit v1.2.3