diff --git a/src/Graphics/Resources/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs index 65a3b9a..e293229 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -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;