From 3e7920bc92cdae62b2f313aae155868de0351691 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Fri, 12 Jan 2024 22:23:48 -0700 Subject: [PATCH] Added to cleanup --- src/main.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/main.c b/src/main.c index d825978..e11d196 100644 --- a/src/main.c +++ b/src/main.c @@ -3107,6 +3107,53 @@ void main_loop(GLFWwindow* window, VulkanContext* context) { void cleanup(GLFWwindow* window, VulkanContext* context) { if(context != 0) { if(context->instance != VK_NULL_HANDLE) { + if(context->extra_graphics_pool != VK_NULL_HANDLE) { + vkDestroyCommandPool(context->device, context->extra_graphics_pool, 0); + } + + if(context->render_pass != VK_NULL_HANDLE) { + vkDestroyRenderPass(context->device, context->render_pass, 0); + } + + if(context->depth_image != VK_NULL_HANDLE) { + vkDestroyImage(context->device, context->depth_image, 0); + } + + for(uint32_t i = 0; i < context->swapchain_image_count; i++) { + vkDestroyFramebuffer(context->device, context->swapchain_framebuffers[i], 0); + vkDestroyImageView(context->device, context->swapchain_image_views[i], 0); + } + + if(context->swapchain != VK_NULL_HANDLE) { + vkDestroySwapchainKHR(context->device, context->swapchain, 0); + } + + for(uint32_t i = 0; i < context->max_frames_in_flight; i++) { + vkDestroySemaphore(context->device, context->image_available_semaphores[i], 0); + vkDestroySemaphore(context->device, context->render_finished_semaphores[i], 0); + vkDestroyFence(context->device, context->in_flight_fences[i], 0); + } + + if(context->depth_image_view != VK_NULL_HANDLE) { + vkDestroyImageView(context->device, context->depth_image_view, 0); + } + + if(context->depth_image_memory != VK_NULL_HANDLE) { + vkFreeMemory(context->device, context->depth_image_memory, 0); + } + + if(context->graphics_command_pool != VK_NULL_HANDLE) { + vkDestroyCommandPool(context->device, context->graphics_command_pool, 0); + } + + if(context->transfer_command_pool != VK_NULL_HANDLE) { + vkDestroyCommandPool(context->device, context->transfer_command_pool, 0); + } + + if(context->swapchain_command_buffers != NULL) { + free(context->swapchain_command_buffers); + } + if(context->swapchain != VK_NULL_HANDLE) { vkDestroySwapchainKHR(context->device, context->swapchain, 0); }