void CreateRenderpass(MgGraphicsDeviceCreateInfo createInfo) { bool isStencilFormat = AmtFormatExtensions.IsStencilFormat(createInfo.DepthStencil); var attachments = new[] { // Color attachment[0] new MgAttachmentDescription { Format = createInfo.Color, // TODO : multisampling Samples = createInfo.Samples, LoadOp = MgAttachmentLoadOp.CLEAR, StoreOp = MgAttachmentStoreOp.STORE, StencilLoadOp = MgAttachmentLoadOp.DONT_CARE, StencilStoreOp = MgAttachmentStoreOp.DONT_CARE, InitialLayout = MgImageLayout.COLOR_ATTACHMENT_OPTIMAL, FinalLayout = MgImageLayout.COLOR_ATTACHMENT_OPTIMAL, }, // Depth attachment[1] new MgAttachmentDescription { Format = createInfo.DepthStencil, // TODO : multisampling Samples = createInfo.Samples, LoadOp = MgAttachmentLoadOp.CLEAR, StoreOp = MgAttachmentStoreOp.STORE, // activate stencil if needed StencilLoadOp = isStencilFormat ? MgAttachmentLoadOp.CLEAR : MgAttachmentLoadOp.DONT_CARE, StencilStoreOp = isStencilFormat ? MgAttachmentStoreOp.STORE : MgAttachmentStoreOp.DONT_CARE, InitialLayout = MgImageLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL, FinalLayout = MgImageLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL, } }; var colorReference = new MgAttachmentReference { Attachment = 0, Layout = MgImageLayout.COLOR_ATTACHMENT_OPTIMAL, }; var depthReference = new MgAttachmentReference { Attachment = 1, Layout = MgImageLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL, }; var subpass = new MgSubpassDescription { PipelineBindPoint = MgPipelineBindPoint.GRAPHICS, Flags = 0, InputAttachments = null, ColorAttachmentCount = 1, ColorAttachments = new[] { colorReference }, ResolveAttachments = null, DepthStencilAttachment = depthReference, PreserveAttachments = null, }; var renderPassInfo = new MgRenderPassCreateInfo { Attachments = attachments, Subpasses = new[] { subpass }, Dependencies = null, }; Result err; IMgRenderPass renderPass; err = mConfiguration.Device.CreateRenderPass(renderPassInfo, null, out renderPass); Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS"); mRenderpass = renderPass; }