Blend state ABI break

main
cosmonaut 2022-02-25 17:50:08 -08:00
parent 9028a8b1a0
commit 32b269526f
5 changed files with 12 additions and 23 deletions

@ -1 +1 @@
Subproject commit 5a411e482ebe619a7e85c44584faa5bd71b7ee3b
Subproject commit 61ec63b71f9fc3163ef5a8d985fbb53e3f02dbf9

View File

@ -154,5 +154,6 @@ namespace MoonWorks.Graphics
{
public TextureFormat Format;
public SampleCount SampleCount;
public ColorAttachmentBlendState BlendState;
}
}

View File

@ -49,15 +49,6 @@ namespace MoonWorks.Graphics
GCHandleType.Pinned
);
var colorTargetBlendStates = stackalloc Refresh.ColorTargetBlendState[
colorBlendState.ColorTargetBlendStates.Length
];
for (var i = 0; i < colorBlendState.ColorTargetBlendStates.Length; i += 1)
{
colorTargetBlendStates[i] = colorBlendState.ColorTargetBlendStates[i].ToRefreshColorTargetBlendState();
}
var colorAttachmentDescriptions = stackalloc Refresh.ColorAttachmentDescription[
(int) attachmentInfo.ColorAttachmentDescriptions.Length
];
@ -66,14 +57,13 @@ namespace MoonWorks.Graphics
{
colorAttachmentDescriptions[i].format = (Refresh.TextureFormat) attachmentInfo.ColorAttachmentDescriptions[i].Format;
colorAttachmentDescriptions[i].sampleCount = (Refresh.SampleCount) attachmentInfo.ColorAttachmentDescriptions[i].SampleCount;
colorAttachmentDescriptions[i].blendState = attachmentInfo.ColorAttachmentDescriptions[i].BlendState.ToRefresh();
}
Refresh.GraphicsPipelineCreateInfo refreshGraphicsPipelineCreateInfo;
refreshGraphicsPipelineCreateInfo.colorBlendState.logicOpEnable = Conversions.BoolToByte(colorBlendState.LogicOpEnable);
refreshGraphicsPipelineCreateInfo.colorBlendState.logicOp = (Refresh.LogicOp) colorBlendState.LogicOp;
refreshGraphicsPipelineCreateInfo.colorBlendState.blendStates = (IntPtr) colorTargetBlendStates;
refreshGraphicsPipelineCreateInfo.colorBlendState.blendStateCount = (uint) colorBlendState.ColorTargetBlendStates.Length;
refreshGraphicsPipelineCreateInfo.colorBlendState.blendConstants[0] = colorBlendState.BlendConstants.R;
refreshGraphicsPipelineCreateInfo.colorBlendState.blendConstants[1] = colorBlendState.BlendConstants.G;
refreshGraphicsPipelineCreateInfo.colorBlendState.blendConstants[2] = colorBlendState.BlendConstants.B;

View File

@ -2,7 +2,7 @@
namespace MoonWorks.Graphics
{
public struct ColorTargetBlendState
public struct ColorAttachmentBlendState
{
/// <summary>
/// If disabled, no blending will occur.
@ -43,7 +43,7 @@ namespace MoonWorks.Graphics
/// </summary>
public BlendFactor SourceColorBlendFactor;
public static readonly ColorTargetBlendState Additive = new ColorTargetBlendState
public static readonly ColorAttachmentBlendState Additive = new ColorAttachmentBlendState
{
BlendEnable = true,
AlphaBlendOp = BlendOp.Add,
@ -55,7 +55,7 @@ namespace MoonWorks.Graphics
DestinationAlphaBlendFactor = BlendFactor.One
};
public static readonly ColorTargetBlendState AlphaBlend = new ColorTargetBlendState
public static readonly ColorAttachmentBlendState AlphaBlend = new ColorAttachmentBlendState
{
BlendEnable = true,
AlphaBlendOp = BlendOp.Add,
@ -67,7 +67,7 @@ namespace MoonWorks.Graphics
DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha
};
public static readonly ColorTargetBlendState NonPremultiplied = new ColorTargetBlendState
public static readonly ColorAttachmentBlendState NonPremultiplied = new ColorAttachmentBlendState
{
BlendEnable = true,
AlphaBlendOp = BlendOp.Add,
@ -79,7 +79,7 @@ namespace MoonWorks.Graphics
DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha
};
public static readonly ColorTargetBlendState Opaque = new ColorTargetBlendState
public static readonly ColorAttachmentBlendState Opaque = new ColorAttachmentBlendState
{
BlendEnable = true,
AlphaBlendOp = BlendOp.Add,
@ -91,21 +91,21 @@ namespace MoonWorks.Graphics
DestinationAlphaBlendFactor = BlendFactor.Zero
};
public static readonly ColorTargetBlendState None = new ColorTargetBlendState
public static readonly ColorAttachmentBlendState None = new ColorAttachmentBlendState
{
BlendEnable = false,
ColorWriteMask = ColorComponentFlags.RGBA
};
public static readonly ColorTargetBlendState Disable = new ColorTargetBlendState
public static readonly ColorAttachmentBlendState Disable = new ColorAttachmentBlendState
{
BlendEnable = false,
ColorWriteMask = ColorComponentFlags.None
};
public Refresh.ColorTargetBlendState ToRefreshColorTargetBlendState()
public Refresh.ColorAttachmentBlendState ToRefresh()
{
return new Refresh.ColorTargetBlendState
return new Refresh.ColorAttachmentBlendState
{
blendEnable = Conversions.BoolToByte(BlendEnable),
alphaBlendOp = (Refresh.BlendOp) AlphaBlendOp,

View File

@ -2,13 +2,11 @@
{
/// <summary>
/// Describes how the graphics pipeline will blend colors.
/// You must provide one ColorTargetBlendState per color target in the pipeline.
/// </summary>
public unsafe struct ColorBlendState
{
public bool LogicOpEnable;
public LogicOp LogicOp;
public BlendConstants BlendConstants;
public ColorTargetBlendState[] ColorTargetBlendStates;
}
}