Skip to content

Commit 708cfec

Browse files
bors[bot]demurgos
andauthored
Merge #3043
3043: Fix validation errors in quad example r=kvark a=demurgos PR checklist: - [x] `make` succeeds (on *nix) - [x] `make reftests` succeeds - [x] tested examples with the following backends: vulkan, gl (wasm) - [x] `rustfmt` run on changed code Fix validation errors in quad example This commit fixes the Vulkan validation errors for the `quad` example: - The framebuffer is destroyed without waiting for the command buffer to be executed. - The swapchain is not destroyed. This commit also adds a small comment explaining why `main` extends the lifetime of `window` beyond its initial scope. Co-authored-by: Charles Samborski <demurgos@demurgos.net>
2 parents 8c8c3cd + 8e8d801 commit 708cfec

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)