Skip to content

Commit a9605ea

Browse files
author
Marijn Stollenga
committed
bug fix, removing early deinit
1 parent 557cee6 commit a9605ea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,9 @@ fn chooseSwapExtent(capabilities: c.VkSurfaceCapabilitiesKHR) c.VkExtent2D {
591591
}
592592

593593
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+
596597
const surfaceFormat = chooseSwapSurfaceFormat(swapChainSupport.formats.toSlice());
597598
const presentMode = chooseSwapPresentMode(swapChainSupport.presentModes.toSlice());
598599
const extent = chooseSwapExtent(swapChainSupport.capabilities);
@@ -811,7 +812,8 @@ fn isDeviceSuitable(allocator: *Allocator, device: c.VkPhysicalDevice) !bool {
811812

812813
var swapChainAdequate = false;
813814
if (extensionsSupported) {
814-
const swapChainSupport = try querySwapChainSupport(allocator, device);
815+
var swapChainSupport = try querySwapChainSupport(allocator, device);
816+
defer swapChainSupport.deinit();
815817
swapChainAdequate = swapChainSupport.formats.len != 0 and swapChainSupport.presentModes.len != 0;
816818
}
817819

@@ -820,7 +822,6 @@ fn isDeviceSuitable(allocator: *Allocator, device: c.VkPhysicalDevice) !bool {
820822

821823
fn querySwapChainSupport(allocator: *Allocator, device: c.VkPhysicalDevice) !SwapChainSupportDetails {
822824
var details = SwapChainSupportDetails.init(allocator);
823-
defer details.deinit();
824825

825826
try checkSuccess(c.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface, &details.capabilities));
826827

0 commit comments

Comments
 (0)