internal Framebuffer(Device parent, RenderPass renderPass, ref FramebufferCreateInfo createInfo, ref AllocationCallbacks?allocator) { Parent = parent; RenderPass = renderPass; Allocator = allocator; fixed(long *attachmentsPtr = createInfo.Attachments) { createInfo.ToNative(out FramebufferCreateInfo.Native nativeCreateInfo, attachmentsPtr, renderPass); long handle; Result result = vkCreateFramebuffer(Parent, &nativeCreateInfo, NativeAllocator, &handle); VulkanException.ThrowForInvalidResult(result); Handle = handle; } }
// Helper function to create a framebuffer from a renderpass and set of render targets private static Vk.Framebuffer CreateFramebuffer(Vk.RenderPass rp, List <RenderTarget> rts, Point size) { // Increment the ref count of the render targets as they are now part of a new framebuffer foreach (var rt in rts) { rt.IncRefCount(); } // Create the framebuffer var fbci = new Vk.FramebufferCreateInfo( rts.Select(rt => rt.VkView).ToArray(), size.X, size.Y, layers: 1 ); return(rp.CreateFramebuffer(fbci)); }
/// <summary> /// Create a new framebuffer object. /// </summary> /// <param name="createInfo"> /// The structure which describes additional information about framebuffer creation. /// </param> /// <param name="allocator">Controls host memory allocation.</param> /// <returns>The resulting framebuffer object.</returns> /// <exception cref="VulkanException">Vulkan returns an error code.</exception> public Framebuffer CreateFramebuffer(FramebufferCreateInfo createInfo, AllocationCallbacks?allocator = null) { return(new Framebuffer(Parent, this, ref createInfo, ref allocator)); }