void CreateFramebuffers() { if (swapchainFramebuffers != null) { foreach (var fb in swapchainFramebuffers) { VK.DestroyFramebuffer(device, fb, alloc); } } swapchainFramebuffers = new List <VkFramebuffer>(swapchainImageViews.Count); for (int i = 0; i < swapchainImageViews.Count; i++) { var attachments = new Native <VkImageView>(swapchainImageViews[i]); var info = new VkFramebufferCreateInfo(); info.sType = CSGL.Vulkan.VkStructureType.FramebufferCreateInfo; info.renderPass = renderPass; info.attachmentCount = 1; info.pAttachments = attachments.Address; info.width = swapchainExtent.width; info.height = swapchainExtent.height; info.layers = 1; VkFramebuffer temp; var result = VK.CreateFramebuffer(device, ref info, alloc, out temp); swapchainFramebuffers.Add(temp); attachments.Dispose(); } }
public void Dispose() { VK.DestroySemaphore(device, imageAvailableSemaphore, alloc); VK.DestroySemaphore(device, renderFinishedSemaphore, alloc); VK.DestroyCommandPool(device, commandPool, alloc); foreach (var fb in swapchainFramebuffers) { VK.DestroyFramebuffer(device, fb, alloc); } VK.DestroyPipeline(device, pipeline, alloc); VK.DestroyPipelineLayout(device, pipelineLayout, alloc); VK.DestroyRenderPass(device, renderPass, alloc); foreach (var iv in swapchainImageViews) { VK.DestroyImageView(device, iv, alloc); } destroySwapchain(device, swapchain, alloc); VK.DestroyDevice(device, alloc); destroySurface(instance, surface, alloc); VK.DestroyInstance(instance, alloc); GLFW.Terminate(); }