Skip to content

Commit 8e8d801

Browse files
committed
Fix swapchain validation errors in quad example
This commit fixes the Vulkan validation errors caused by not destroying the swapchain. It also fixes a typo and adds a small comment explaining why `main` extends the lifetime of `window` beyond its initial scope.
1 parent 8c8c3cd commit 8e8d801

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/quad/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ fn main() {
121121
.expect("Failed to create an instance!");
122122
let surface = instance.create_surface(&window).expect("Failed to create a surface!");
123123
let adapters = instance.enumerate_adapters();
124+
// Return `window` so it is not dropped: dropping it invalidates `surface`.
124125
(window, instance, adapters, surface)
125126
};
126127
#[cfg(feature = "gl")]
@@ -619,7 +620,7 @@ where
619620
submission_complete_fences.push(
620621
device
621622
.create_fence(true)
622-
.expect("Could not create semaphore"),
623+
.expect("Could not create fence"),
623624
);
624625
cmd_buffers.push(cmd_pools[i].allocate_one(command::Level::Primary));
625626
}
@@ -927,6 +928,8 @@ where
927928
}
928929
self.device
929930
.destroy_render_pass(ManuallyDrop::into_inner(ptr::read(&self.render_pass)));
931+
self.surface
932+
.unconfigure_swapchain(&self.device);
930933
self.device
931934
.free_memory(ManuallyDrop::into_inner(ptr::read(&self.buffer_memory)));
932935
self.device

0 commit comments

Comments
 (0)