@@ -591,8 +591,9 @@ fn chooseSwapExtent(capabilities: c.VkSurfaceCapabilitiesKHR) c.VkExtent2D {
591
591
}
592
592
593
593
fn createSwapChain (allocator : * Allocator ) ! void {
594
- const swapChainSupport = try querySwapChainSupport (allocator , physicalDevice );
595
-
594
+ var swapChainSupport = try querySwapChainSupport (allocator , physicalDevice );
595
+ defer swapChainSupport .deinit ();
596
+
596
597
const surfaceFormat = chooseSwapSurfaceFormat (swapChainSupport .formats .toSlice ());
597
598
const presentMode = chooseSwapPresentMode (swapChainSupport .presentModes .toSlice ());
598
599
const extent = chooseSwapExtent (swapChainSupport .capabilities );
@@ -811,7 +812,8 @@ fn isDeviceSuitable(allocator: *Allocator, device: c.VkPhysicalDevice) !bool {
811
812
812
813
var swapChainAdequate = false ;
813
814
if (extensionsSupported ) {
814
- const swapChainSupport = try querySwapChainSupport (allocator , device );
815
+ var swapChainSupport = try querySwapChainSupport (allocator , device );
816
+ defer swapChainSupport .deinit ();
815
817
swapChainAdequate = swapChainSupport .formats .len != 0 and swapChainSupport .presentModes .len != 0 ;
816
818
}
817
819
@@ -820,7 +822,6 @@ fn isDeviceSuitable(allocator: *Allocator, device: c.VkPhysicalDevice) !bool {
820
822
821
823
fn querySwapChainSupport (allocator : * Allocator , device : c.VkPhysicalDevice ) ! SwapChainSupportDetails {
822
824
var details = SwapChainSupportDetails .init (allocator );
823
- defer details .deinit ();
824
825
825
826
try checkSuccess (c .vkGetPhysicalDeviceSurfaceCapabilitiesKHR (device , surface , & details .capabilities ));
826
827
0 commit comments