Fixed resize memory leak
This commit is contained in:
parent
519a8e9b7a
commit
6f33a9a3e4
1 changed files with 6 additions and 7 deletions
13
src/main.c
13
src/main.c
|
|
@ -1018,6 +1018,7 @@ void createSyncObjects(Application *app) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanupSwapChain(Application *app) {
|
void cleanupSwapChain(Application *app) {
|
||||||
|
|
||||||
for (size_t i = 0; i < app->swapChainFramebufferCount; i++) {
|
for (size_t i = 0; i < app->swapChainFramebufferCount; i++) {
|
||||||
vkDestroyFramebuffer(app->device, app->swapChainFramebuffers[i], NULL);
|
vkDestroyFramebuffer(app->device, app->swapChainFramebuffers[i], NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -1026,6 +1027,10 @@ void cleanupSwapChain(Application *app) {
|
||||||
vkDestroyImageView(app->device, app->swapChainImageViews[i], NULL);
|
vkDestroyImageView(app->device, app->swapChainImageViews[i], NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(app->swapChainFramebuffers);
|
||||||
|
free(app->swapChainImageViews);
|
||||||
|
free(app->swapChainImages);
|
||||||
|
|
||||||
vkDestroySwapchainKHR(app->device, app->swapChain, NULL);
|
vkDestroySwapchainKHR(app->device, app->swapChain, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1038,10 +1043,7 @@ void recreateSwapChain(Application *app) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vkDeviceWaitIdle(app->device);
|
vkDeviceWaitIdle(app->device);
|
||||||
|
cleanupSwapChain(app);
|
||||||
free(app->swapChainFramebuffers);
|
|
||||||
free(app->swapChainImageViews);
|
|
||||||
free(app->swapChainImages);
|
|
||||||
|
|
||||||
createSwapChain(app);
|
createSwapChain(app);
|
||||||
createImageViews(app);
|
createImageViews(app);
|
||||||
|
|
@ -1144,9 +1146,6 @@ void mainLoop(Application *app) {
|
||||||
|
|
||||||
void cleanup(Application *app) {
|
void cleanup(Application *app) {
|
||||||
cleanupSwapChain(app);
|
cleanupSwapChain(app);
|
||||||
free(app->swapChainFramebuffers);
|
|
||||||
free(app->swapChainImageViews);
|
|
||||||
free(app->swapChainImages);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
|
for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
|
||||||
vkDestroySemaphore(app->device, app->imageAvailableSemaphores[i], NULL);
|
vkDestroySemaphore(app->device, app->imageAvailableSemaphores[i], NULL);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue