public AttachmentDescription2KHR ( StructureType sType = StructureType.AttachmentDescription2, void *pNext = default, AttachmentDescriptionFlags flags = default, Format format = default, SampleCountFlags samples = default, AttachmentLoadOp loadOp = default, AttachmentStoreOp storeOp = default, AttachmentLoadOp stencilLoadOp = default, AttachmentStoreOp stencilStoreOp = default, ImageLayout initialLayout = default, ImageLayout finalLayout = default ) { SType = sType; PNext = pNext; Flags = flags; Format = format; Samples = samples; LoadOp = loadOp; StoreOp = storeOp; StencilLoadOp = stencilLoadOp; StencilStoreOp = stencilStoreOp; InitialLayout = initialLayout; FinalLayout = finalLayout; }
/// <summary> /// Initializes a new instance of the <see cref="AttachmentDescription"/> structure. /// </summary> /// <param name="flags">A bitmask specifying additional properties of the attachment.</param> /// <param name="format"> /// Specifies the format of the image that will be used for the attachment. /// </param> /// <param name="samples">The number of samples of the image.</param> /// <param name="loadOp"> /// Specifies how the contents of color and depth components of the attachment are treated at /// the beginning of the subpass where it is first used. /// </param> /// <param name="storeOp"> /// Specifies how the contents of color and depth components of the attachment are treated at /// the end of the subpass where it is last used. /// </param> /// <param name="stencilLoadOp"> /// Specifies how the contents of stencil components of the attachment are treated at the /// beginning of the subpass where it is first used, and must be one of the same values /// allowed for <see cref="LoadOp"/> above. /// </param> /// <param name="stencilStoreOp"> /// Specifies how the contents of stencil components of the attachment are treated at the end /// of the last subpass where it is used, and must be one of the same values allowed for <see /// cref="StoreOp"/> above. /// </param> /// <param name="initialLayout"> /// The layout the attachment image subresource will be in when a render pass instance begins. /// </param> /// <param name="finalLayout"> /// The layout the attachment image subresource will be transitioned to when a render pass /// instance ends. During a render pass instance, an attachment can use a different layout in /// each subpass, if desired. /// </param> public AttachmentDescription( AttachmentDescriptions flags, Format format, SampleCounts samples, AttachmentLoadOp loadOp, AttachmentStoreOp storeOp, AttachmentLoadOp stencilLoadOp, AttachmentStoreOp stencilStoreOp, ImageLayout initialLayout, ImageLayout finalLayout) { Flags = flags; Format = format; Samples = samples; LoadOp = loadOp; StoreOp = storeOp; StencilLoadOp = stencilLoadOp; StencilStoreOp = stencilStoreOp; InitialLayout = initialLayout; FinalLayout = finalLayout; }
public unsafe RenderPass(Api api, SwapChain swapChain, DepthBuffer depthBuffer, AttachmentLoadOp colorBufferLoadOp, AttachmentLoadOp depthBufferLoadOp) { _api = api; var colorAttachment = new AttachmentDescription(); colorAttachment.Format = swapChain.Format; colorAttachment.Samples = SampleCountFlags.SampleCount1Bit; colorAttachment.LoadOp = colorBufferLoadOp; colorAttachment.StoreOp = AttachmentStoreOp.Store; colorAttachment.StencilLoadOp = AttachmentLoadOp.DontCare; colorAttachment.StencilStoreOp = AttachmentStoreOp.DontCare; colorAttachment.InitialLayout = colorBufferLoadOp == AttachmentLoadOp.Clear ? ImageLayout.Undefined : ImageLayout.PresentSrcKhr; colorAttachment.FinalLayout = ImageLayout.PresentSrcKhr; var depthAttachment = new AttachmentDescription(); depthAttachment.Format = depthBuffer.Format; depthAttachment.Samples = SampleCountFlags.SampleCount1Bit; depthAttachment.LoadOp = depthBufferLoadOp; depthAttachment.StoreOp = AttachmentStoreOp.DontCare; depthAttachment.StencilLoadOp = AttachmentLoadOp.DontCare; depthAttachment.StencilStoreOp = AttachmentStoreOp.DontCare; depthAttachment.InitialLayout = depthBufferLoadOp == AttachmentLoadOp.Clear ? ImageLayout.Undefined : ImageLayout.DepthStencilAttachmentOptimal; depthAttachment.FinalLayout = ImageLayout.DepthStencilAttachmentOptimal; var colorAttachmentRef = new AttachmentReference(); colorAttachmentRef.Attachment = 0; colorAttachmentRef.Layout = ImageLayout.ColorAttachmentOptimal; var depthAttachmentRef = new AttachmentReference(); depthAttachmentRef.Attachment = 1; depthAttachmentRef.Layout = ImageLayout.DepthStencilAttachmentOptimal; var subpass = new SubpassDescription(); subpass.PipelineBindPoint = PipelineBindPoint.Graphics; subpass.ColorAttachmentCount = 1; subpass.PColorAttachments = (AttachmentReference *)Unsafe.AsPointer(ref colorAttachmentRef); subpass.PDepthStencilAttachment = (AttachmentReference *)Unsafe.AsPointer(ref depthAttachmentRef); var dependency = new SubpassDependency(); dependency.SrcSubpass = Vk.SubpassExternal; dependency.DstSubpass = 0; dependency.SrcStageMask = PipelineStageFlags.PipelineStageColorAttachmentOutputBit; dependency.SrcAccessMask = 0; dependency.DstStageMask = PipelineStageFlags.PipelineStageColorAttachmentOutputBit; dependency.DstAccessMask = AccessFlags.AccessColorAttachmentReadBit | AccessFlags.AccessColorAttachmentWriteBit; Span <AttachmentDescription> attachments = stackalloc AttachmentDescription[] { colorAttachment, depthAttachment }; var renderPassInfo = new RenderPassCreateInfo(); renderPassInfo.SType = StructureType.RenderPassCreateInfo; renderPassInfo.AttachmentCount = (uint)attachments.Length; renderPassInfo.PAttachments = (AttachmentDescription *)Unsafe.AsPointer(ref attachments[0]); renderPassInfo.SubpassCount = 1; renderPassInfo.PSubpasses = (SubpassDescription *)Unsafe.AsPointer(ref subpass); renderPassInfo.DependencyCount = 1; renderPassInfo.PDependencies = (SubpassDependency *)Unsafe.AsPointer(ref dependency); Util.Verify( _api.Vk.CreateRenderPass(_api.Vk.CurrentDevice.Value, renderPassInfo, default, out _vkRenderPass),
/// <summary> /// /// </summary> public AttachmentDescription(AttachmentDescriptionFlags flags, Format format, SampleCountFlags samples, AttachmentLoadOp loadOp, AttachmentStoreOp storeOp, AttachmentLoadOp stencilLoadOp, AttachmentStoreOp stencilStoreOp, ImageLayout initialLayout, ImageLayout finalLayout) { this.Flags = flags; this.Format = format; this.Samples = samples; this.LoadOp = loadOp; this.StoreOp = storeOp; this.StencilLoadOp = stencilLoadOp; this.StencilStoreOp = stencilStoreOp; this.InitialLayout = initialLayout; this.FinalLayout = finalLayout; }