fix graphics pipeline creation

pull/14/head
cosmonaut 2022-02-24 21:31:32 -08:00
parent 48c31b4908
commit b8b10140a9
1 changed files with 11 additions and 6 deletions

View File

@ -48,10 +48,6 @@ namespace MoonWorks.Graphics
viewportState.Scissors,
GCHandleType.Pinned
);
var colorAttachmentDescriptionsHandle = GCHandle.Alloc(
attachmentInfo.colorAttachmentDescriptions,
GCHandleType.Pinned
);
var colorTargetBlendStates = stackalloc Refresh.ColorTargetBlendState[
colorBlendState.ColorTargetBlendStates.Length
@ -62,6 +58,16 @@ namespace MoonWorks.Graphics
colorTargetBlendStates[i] = colorBlendState.ColorTargetBlendStates[i].ToRefreshColorTargetBlendState();
}
var colorAttachmentDescriptions = stackalloc Refresh.ColorAttachmentDescription[
(int) attachmentInfo.colorAttachmentCount
];
for (var i = 0; i < attachmentInfo.colorAttachmentCount; i += 1)
{
colorAttachmentDescriptions[i].format = (Refresh.TextureFormat) attachmentInfo.colorAttachmentDescriptions[i].format;
colorAttachmentDescriptions[i].sampleCount = (Refresh.SampleCount) attachmentInfo.colorAttachmentDescriptions[i].sampleCount;
}
Refresh.GraphicsPipelineCreateInfo refreshGraphicsPipelineCreateInfo;
refreshGraphicsPipelineCreateInfo.colorBlendState.logicOpEnable = Conversions.BoolToByte(colorBlendState.LogicOpEnable);
@ -120,7 +126,7 @@ namespace MoonWorks.Graphics
refreshGraphicsPipelineCreateInfo.primitiveType = (Refresh.PrimitiveType) primitiveType;
refreshGraphicsPipelineCreateInfo.attachmentInfo.colorAttachmentCount = attachmentInfo.colorAttachmentCount;
refreshGraphicsPipelineCreateInfo.attachmentInfo.colorAttachmentDescriptions = colorAttachmentDescriptionsHandle.AddrOfPinnedObject();
refreshGraphicsPipelineCreateInfo.attachmentInfo.colorAttachmentDescriptions = (IntPtr) colorAttachmentDescriptions;
refreshGraphicsPipelineCreateInfo.attachmentInfo.depthStencilFormat = (Refresh.TextureFormat) attachmentInfo.depthStencilFormat;
refreshGraphicsPipelineCreateInfo.attachmentInfo.hasDepthStencilAttachment = Conversions.BoolToByte(attachmentInfo.hasDepthStencilAttachment);
@ -130,7 +136,6 @@ namespace MoonWorks.Graphics
vertexBindingsHandle.Free();
viewportHandle.Free();
scissorHandle.Free();
colorAttachmentDescriptionsHandle.Free();
VertexShaderState = vertexShaderState;
FragmentShaderState = fragmentShaderState;