forked from mirror/vulkan-zig
Avoid queueWaitIdle when deinitializing/recreating the swapchain
This commit is contained in:
@@ -89,14 +89,13 @@ pub const Swapchain = struct {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinitExceptSwapchain(self: Swapchain) !void {
|
fn deinitExceptSwapchain(self: Swapchain) void {
|
||||||
_ = try self.gc.vkd.queueWaitIdle(self.gc.present_queue.handle);
|
|
||||||
for (self.swap_images) |si| si.deinit(self.gc);
|
for (self.swap_images) |si| si.deinit(self.gc);
|
||||||
self.gc.vkd.destroySemaphore(self.gc.dev, self.next_image_acquired, null);
|
self.gc.vkd.destroySemaphore(self.gc.dev, self.next_image_acquired, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: Swapchain) void {
|
pub fn deinit(self: Swapchain) void {
|
||||||
self.deinitExceptSwapchain() catch return;
|
self.deinitExceptSwapchain();
|
||||||
self.gc.vkd.destroySwapchainKHR(self.gc.dev, self.handle, null);
|
self.gc.vkd.destroySwapchainKHR(self.gc.dev, self.handle, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ pub const Swapchain = struct {
|
|||||||
const gc = self.gc;
|
const gc = self.gc;
|
||||||
const allocator = self.allocator;
|
const allocator = self.allocator;
|
||||||
const old_handle = self.handle;
|
const old_handle = self.handle;
|
||||||
try self.deinitExceptSwapchain();
|
self.deinitExceptSwapchain();
|
||||||
self.* = try initRecycle(gc, allocator, new_extent, old_handle);
|
self.* = try initRecycle(gc, allocator, new_extent, old_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,6 +224,10 @@ const SwapImage = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: SwapImage, gc: *const GraphicsContext) void {
|
fn deinit(self: SwapImage, gc: *const GraphicsContext) void {
|
||||||
|
// Ignore any error (and the result), and still try to delete the other resources.
|
||||||
|
// If this errors, the error is likely to be triggered elsewhere anyway.
|
||||||
|
const result = gc.vkd.waitForFences(gc.dev, 1, @ptrCast([*]const vk.Fence, &self.frame_fence), vk.TRUE, std.math.maxInt(u64));
|
||||||
|
|
||||||
gc.vkd.destroyImageView(gc.dev, self.view, null);
|
gc.vkd.destroyImageView(gc.dev, self.view, null);
|
||||||
gc.vkd.destroySemaphore(gc.dev, self.image_acquired, null);
|
gc.vkd.destroySemaphore(gc.dev, self.image_acquired, null);
|
||||||
gc.vkd.destroySemaphore(gc.dev, self.render_finished, null);
|
gc.vkd.destroySemaphore(gc.dev, self.render_finished, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user