private void CreateRenderPass() { var attachmentDescs = new[] { new SharpVulkan.AttachmentDescription { Format = backbufferFormat, Samples = SharpVulkan.SampleCountFlags.Sample1, LoadOperation = SharpVulkan.AttachmentLoadOperation.Load, StoreOperation = SharpVulkan.AttachmentStoreOperation.Store, InitialLayout = SharpVulkan.ImageLayout.ColorAttachmentOptimal, FinalLayout = SharpVulkan.ImageLayout.ColorAttachmentOptimal }, new SharpVulkan.AttachmentDescription { Format = depthStencilFormat, Samples = SharpVulkan.SampleCountFlags.Sample1, LoadOperation = SharpVulkan.AttachmentLoadOperation.Load, StoreOperation = SharpVulkan.AttachmentStoreOperation.Store, StencilLoadOperation = SharpVulkan.AttachmentLoadOperation.Load, StencilStoreOperation = SharpVulkan.AttachmentStoreOperation.Store, InitialLayout = SharpVulkan.ImageLayout.DepthStencilAttachmentOptimal, FinalLayout = SharpVulkan.ImageLayout.DepthStencilAttachmentOptimal } }; var colorAttachmentRef = new SharpVulkan.AttachmentReference { Attachment = 0, Layout = SharpVulkan.ImageLayout.ColorAttachmentOptimal }; var depthStencilAttachmentRef = new SharpVulkan.AttachmentReference { Attachment = 1, Layout = SharpVulkan.ImageLayout.DepthStencilAttachmentOptimal }; fixed(SharpVulkan.AttachmentDescription *attachmentDescsPtr = attachmentDescs) { var subpass = new SharpVulkan.SubpassDescription { PipelineBindPoint = SharpVulkan.PipelineBindPoint.Graphics, ColorAttachmentCount = 1, ColorAttachments = new IntPtr(&colorAttachmentRef), DepthStencilAttachment = new IntPtr(&depthStencilAttachmentRef) }; var createInfo = new SharpVulkan.RenderPassCreateInfo { StructureType = SharpVulkan.StructureType.RenderPassCreateInfo, AttachmentCount = (uint)attachmentDescs.Length, Attachments = new IntPtr(attachmentDescsPtr), SubpassCount = 1, Subpasses = new IntPtr(&subpass) }; renderPass = context.Device.CreateRenderPass(ref createInfo); } }
private void CreateRenderPass() { var attachmentDescs = new[] { new SharpVulkan.AttachmentDescription { Format = colorFormat, Samples = SharpVulkan.SampleCountFlags.Sample1, LoadOperation = SharpVulkan.AttachmentLoadOperation.Load, StoreOperation = SharpVulkan.AttachmentStoreOperation.Store, InitialLayout = SharpVulkan.ImageLayout.ShaderReadOnlyOptimal, FinalLayout = SharpVulkan.ImageLayout.ShaderReadOnlyOptimal }, new SharpVulkan.AttachmentDescription { Format = depthStencilFormat, Samples = SharpVulkan.SampleCountFlags.Sample1, LoadOperation = SharpVulkan.AttachmentLoadOperation.Load, StoreOperation = SharpVulkan.AttachmentStoreOperation.Store, StencilLoadOperation = SharpVulkan.AttachmentLoadOperation.Load, StencilStoreOperation = SharpVulkan.AttachmentStoreOperation.Store, InitialLayout = SharpVulkan.ImageLayout.DepthStencilAttachmentOptimal, FinalLayout = SharpVulkan.ImageLayout.DepthStencilAttachmentOptimal } }; var colorAttachmentRef = new SharpVulkan.AttachmentReference { Attachment = 0, Layout = SharpVulkan.ImageLayout.ColorAttachmentOptimal }; var depthStencilAttachmentRef = new SharpVulkan.AttachmentReference { Attachment = 1, Layout = SharpVulkan.ImageLayout.DepthStencilAttachmentOptimal }; var subpassDependencies = new[] { new SharpVulkan.SubpassDependency { SourceSubpass = uint.MaxValue, SourceAccessMask = SharpVulkan.AccessFlags.ShaderRead, SourceStageMask = SharpVulkan.PipelineStageFlags.VertexShader | SharpVulkan.PipelineStageFlags.FragmentShader, DestinationSubpass = 0, DestinationAccessMask = SharpVulkan.AccessFlags.ColorAttachmentRead | SharpVulkan.AccessFlags.ColorAttachmentWrite, DestinationStageMask = SharpVulkan.PipelineStageFlags.ColorAttachmentOutput }, new SharpVulkan.SubpassDependency { SourceSubpass = 0, SourceAccessMask = SharpVulkan.AccessFlags.ColorAttachmentRead | SharpVulkan.AccessFlags.ColorAttachmentWrite, SourceStageMask = SharpVulkan.PipelineStageFlags.ColorAttachmentOutput, DestinationSubpass = uint.MaxValue, DestinationAccessMask = SharpVulkan.AccessFlags.ShaderRead, DestinationStageMask = SharpVulkan.PipelineStageFlags.VertexShader | SharpVulkan.PipelineStageFlags.FragmentShader } }; fixed(SharpVulkan.AttachmentDescription *attachmentDescsPtr = attachmentDescs) fixed(SharpVulkan.SubpassDependency * subpassDependenciesPtr = subpassDependencies) { var subpass = new SharpVulkan.SubpassDescription { PipelineBindPoint = SharpVulkan.PipelineBindPoint.Graphics, ColorAttachmentCount = 1, ColorAttachments = new IntPtr(&colorAttachmentRef), DepthStencilAttachment = new IntPtr(&depthStencilAttachmentRef) }; var createInfo = new SharpVulkan.RenderPassCreateInfo { StructureType = SharpVulkan.StructureType.RenderPassCreateInfo, AttachmentCount = (uint)attachmentDescs.Length, Attachments = new IntPtr(attachmentDescsPtr), SubpassCount = 1, Subpasses = new IntPtr(&subpass), DependencyCount = (uint)subpassDependencies.Length, Dependencies = new IntPtr(subpassDependenciesPtr) }; renderPass = Context.Device.CreateRenderPass(ref createInfo); } }