Dispose of old swapchain after recreating

This previously lead to X11 errors after aggressively resizing the
window
This commit is contained in:
Robin Voetter
2020-07-03 15:48:26 +02:00
parent c6c33d3539
commit e049300d02

View File

@@ -64,6 +64,11 @@ pub const Swapchain = struct {
}, null); }, null);
errdefer gc.vkd.destroySwapchainKHR(gc.dev, handle, null); errdefer gc.vkd.destroySwapchainKHR(gc.dev, handle, null);
if (old_handle != .null_handle) {
// Apparently, the old swapchain handle still needs to be destroyed after recreating.
gc.vkd.destroySwapchainKHR(gc.dev, old_handle, null);
}
const swap_images = try initSwapchainImages(gc, handle, surface_format.format, allocator); const swap_images = try initSwapchainImages(gc, handle, surface_format.format, allocator);
errdefer for (swap_images) |si| si.deinit(gc); errdefer for (swap_images) |si| si.deinit(gc);