| 720 | } |
| 721 | |
| 722 | void Demo::cleanup() { |
| 723 | initialized = false; |
| 724 | auto result = device.waitIdle(); |
| 725 | VERIFY(result == vk::Result::eSuccess); |
| 726 | |
| 727 | device.destroyCommandPool(cmd_pool); |
| 728 | if (separate_present_queue) { |
| 729 | device.destroyCommandPool(present_cmd_pool); |
| 730 | } |
| 731 | |
| 732 | device.destroyDescriptorPool(desc_pool); |
| 733 | |
| 734 | device.destroyPipeline(pipeline); |
| 735 | device.destroyPipelineCache(pipelineCache); |
| 736 | device.destroyRenderPass(render_pass); |
| 737 | device.destroyPipelineLayout(pipeline_layout); |
| 738 | device.destroyDescriptorSetLayout(desc_layout); |
| 739 | |
| 740 | for (const auto &tex : textures) { |
| 741 | device.destroyImageView(tex.view); |
| 742 | device.destroyImage(tex.image); |
| 743 | device.freeMemory(tex.mem); |
| 744 | device.destroySampler(tex.sampler); |
| 745 | } |
| 746 | |
| 747 | device.destroyImageView(depth.view); |
| 748 | device.destroyImage(depth.image); |
| 749 | device.freeMemory(depth.mem); |
| 750 | |
| 751 | for (auto &swapchain_resource : swapchain_resources) { |
| 752 | device.destroyFramebuffer(swapchain_resource.framebuffer); |
| 753 | device.destroyImageView(swapchain_resource.view); |
| 754 | device.destroySemaphore(swapchain_resource.draw_complete_semaphore); |
| 755 | if (separate_present_queue) { |
| 756 | device.destroySemaphore(swapchain_resource.image_ownership_semaphore); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | device.destroySwapchainKHR(swapchain); |
| 761 | |
| 762 | for (const auto &submission_resource : submission_resources) { |
| 763 | device.destroyFence(submission_resource.fence); |
| 764 | device.destroySemaphore(submission_resource.image_acquired_semaphore); |
| 765 | device.destroyBuffer(submission_resource.uniform_buffer); |
| 766 | device.unmapMemory(submission_resource.uniform_memory); |
| 767 | device.freeMemory(submission_resource.uniform_memory); |
| 768 | } |
| 769 | |
| 770 | device.destroy(); |
| 771 | inst.destroySurfaceKHR(surface); |
| 772 | |
| 773 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 774 | if (wsi_platform == WsiPlatform::xlib) { |
| 775 | XDestroyWindow(xlib_display, xlib_window); |
| 776 | XCloseDisplay(xlib_display); |
| 777 | } |
| 778 | #endif |
| 779 | #if defined(VK_USE_PLATFORM_XCB_KHR) |