aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Vulkan/PipelineBase.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-02-19 22:37:37 -0300
committerGitHub <noreply@github.com>2023-02-19 22:37:37 -0300
commit7aa430f1a51fd793971992b4454540975222b848 (patch)
treee6a33e3df7aa5155b7c597b2ff226178f57434d1 /Ryujinx.Graphics.Vulkan/PipelineBase.cs
parent6bf460e1041b969a453dc40ee6fb83164739bf9c (diff)
Add support for advanced blend (part 1/2) (#2801)1.1.626
* Add blend microcode registers * Add advanced blend support using host extension * Remove debug message * Use pre-generated table for blend functions * XML docs * Rename AdvancedBlendMode to AdvancedBlendOp for consistency * Remove redundant code * Fix some advanced blend related issues on Vulkan * Formatting
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/PipelineBase.cs')
-rw-r--r--Ryujinx.Graphics.Vulkan/PipelineBase.cs54
1 files changed, 50 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/Ryujinx.Graphics.Vulkan/PipelineBase.cs
index 8ed39ee2..f779305d 100644
--- a/Ryujinx.Graphics.Vulkan/PipelineBase.cs
+++ b/Ryujinx.Graphics.Vulkan/PipelineBase.cs
@@ -112,11 +112,9 @@ namespace Ryujinx.Graphics.Vulkan
var defaultScale = new Vector4<float> { X = 1f, Y = 0f, Z = 0f, W = 0f };
new Span<Vector4<float>>(_renderScale).Fill(defaultScale);
- _newState.Initialize();
- _newState.LineWidth = 1f;
- _newState.SamplesCount = 1;
+ _storedBlend = new PipelineColorBlendAttachmentState[Constants.MaxRenderTargets];
- _storedBlend = new PipelineColorBlendAttachmentState[8];
+ _newState.Initialize();
}
public void Initialize()
@@ -676,6 +674,49 @@ namespace Ryujinx.Graphics.Vulkan
// to avoid creating one version of the shader per reference value used.
}
+ public void SetBlendState(AdvancedBlendDescriptor blend)
+ {
+ for (int index = 0; index < Constants.MaxRenderTargets; index++)
+ {
+ ref var vkBlend = ref _newState.Internal.ColorBlendAttachmentState[index];
+
+ if (index == 0)
+ {
+ var blendOp = blend.Op.Convert();
+
+ vkBlend = new PipelineColorBlendAttachmentState(
+ blendEnable: true,
+ colorBlendOp: blendOp,
+ alphaBlendOp: blendOp,
+ colorWriteMask: vkBlend.ColorWriteMask);
+
+ if (Gd.Capabilities.SupportsBlendEquationAdvancedNonPreMultipliedSrcColor)
+ {
+ _newState.AdvancedBlendSrcPreMultiplied = blend.SrcPreMultiplied;
+ }
+
+ if (Gd.Capabilities.SupportsBlendEquationAdvancedCorrelatedOverlap)
+ {
+ _newState.AdvancedBlendOverlap = blend.Overlap.Convert();
+ }
+ }
+ else
+ {
+ vkBlend = new PipelineColorBlendAttachmentState(
+ colorWriteMask: vkBlend.ColorWriteMask);
+ }
+
+ if (vkBlend.ColorWriteMask == 0)
+ {
+ _storedBlend[index] = vkBlend;
+
+ vkBlend = new PipelineColorBlendAttachmentState();
+ }
+ }
+
+ SignalStateChange();
+ }
+
public void SetBlendState(int index, BlendDescriptor blend)
{
ref var vkBlend = ref _newState.Internal.ColorBlendAttachmentState[index];
@@ -709,6 +750,11 @@ namespace Ryujinx.Graphics.Vulkan
blend.BlendConstant.Blue,
blend.BlendConstant.Alpha);
+ // Reset advanced blend state back defaults to the cache to help the pipeline cache.
+ _newState.AdvancedBlendSrcPreMultiplied = true;
+ _newState.AdvancedBlendDstPreMultiplied = true;
+ _newState.AdvancedBlendOverlap = BlendOverlapEXT.UncorrelatedExt;
+
SignalStateChange();
}