scop
a small 3D object loader
Loading...
Searching...
No Matches
VulkanClean.cpp
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* VulkanClean.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: rbourgea <rbourgea@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/01/11 06:57:10 by rbourgea #+# #+# */
9/* Updated: 2024/04/02 22:09:35 by rbourgea ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "VulkanApp.hpp"
14
17
18 vkDestroyPipeline(device, graphicsPipeline, nullptr);
19 vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
20 vkDestroyRenderPass(device, renderPass, nullptr);
21
22 for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
23 vkDestroyBuffer(device, uniformBuffers[i], nullptr);
24 vkFreeMemory(device, uniformBuffersMemory[i], nullptr);
25 }
26
27 vkDestroyDescriptorPool(device, descriptorPool, nullptr);
28
29 vkDestroySampler(device, textureSampler, nullptr);
30 vkDestroyImageView(device, textureImageView, nullptr);
31
32 vkDestroyImage(device, textureImage, nullptr);
33 vkFreeMemory(device, textureImageMemory, nullptr);
34
35 vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
36
37 vkDestroyBuffer(device, indexBuffer, nullptr);
38 vkFreeMemory(device, indexBufferMemory, nullptr);
39
40 vkDestroyBuffer(device, vertexBuffer, nullptr);
41 vkFreeMemory(device, vertexBufferMemory, nullptr);
42
43 for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
44 vkDestroySemaphore(device, renderFinishedSemaphores[i], nullptr);
45 vkDestroySemaphore(device, imageAvailableSemaphores[i], nullptr);
46 vkDestroyFence(device, inFlightFences[i], nullptr);
47 }
48
49 vkDestroyCommandPool(device, commandPool, nullptr);
50
51 vkDestroyDevice(device, nullptr);
52
53 if (debugMode) {
55 }
56
57 vkDestroySurfaceKHR(instance, surface, nullptr);
58 vkDestroyInstance(instance, nullptr);
59
60 glfwDestroyWindow(window);
61
62 glfwTerminate();
63}
64
66 vkDestroyImageView(device, depthImageView, nullptr);
67 vkDestroyImage(device, depthImage, nullptr);
68 vkFreeMemory(device, depthImageMemory, nullptr);
69
70 vkDestroyImageView(device, colorImageView, nullptr);
71 vkDestroyImage(device, colorImage, nullptr);
72 vkFreeMemory(device, colorImageMemory, nullptr);
73
74 for (auto framebuffer : swapChainFramebuffers) {
75 vkDestroyFramebuffer(device, framebuffer, nullptr);
76 }
77
78 for (auto imageView : swapChainImageViews) {
79 vkDestroyImageView(device, imageView, nullptr);
80 }
81
82 vkDestroySwapchainKHR(device, swapChain, nullptr);
83}
84
86 if (vertexBuffer != VK_NULL_HANDLE) {
87 vkDestroyBuffer(device, vertexBuffer, nullptr);
88 vertexBuffer = VK_NULL_HANDLE;
89 }
90
91 if (vertexBufferMemory != VK_NULL_HANDLE) {
92 vkFreeMemory(device, vertexBufferMemory, nullptr);
93 vertexBufferMemory = VK_NULL_HANDLE;
94 }
95}
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks *pAllocator)
const int MAX_FRAMES_IN_FLIGHT
Definition VulkanApp.hpp:45
constexpr bool debugMode
Definition VulkanApp.hpp:61
GLFWwindow * window
VkDevice device
VkImageView textureImageView
std::vector< VkDeviceMemory > uniformBuffersMemory
void cleanupVertexBuffer()
std::vector< VkSemaphore > renderFinishedSemaphores
VkBuffer indexBuffer
void cleanupSwapChain()
VkRenderPass renderPass
VkSurfaceKHR surface
VkSampler textureSampler
VkImage textureImage
VkDeviceMemory textureImageMemory
VkDeviceMemory colorImageMemory
std::vector< VkFence > inFlightFences
VkPipelineLayout pipelineLayout
std::vector< VkFramebuffer > swapChainFramebuffers
VkPipeline graphicsPipeline
std::vector< VkSemaphore > imageAvailableSemaphores
VkDescriptorPool descriptorPool
VkImage colorImage
std::vector< VkBuffer > uniformBuffers
VkInstance instance
VkDeviceMemory indexBufferMemory
VkBuffer vertexBuffer
VkDebugUtilsMessengerEXT debugMessenger
VkDeviceMemory vertexBufferMemory
VkImage depthImage
VkDeviceMemory depthImageMemory
void cleanup()
VkCommandPool commandPool
VkImageView colorImageView
VkImageView depthImageView
std::vector< VkImageView > swapChainImageViews
VkSwapchainKHR swapChain
VkDescriptorSetLayout descriptorSetLayout