Add support for advanced blend (part 1/2) (#2801)
* 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
This commit is contained in:
parent
6bf460e104
commit
7aa430f1a5
27 changed files with 5605 additions and 14 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue