Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PresentFuture: Avoid flushing twice on flush error #1889

Merged
merged 1 commit into from
May 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions vulkano/src/swapchain/swapchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,7 @@ where
// If `flushed` already contains `true`, then `build_submission` will return `Empty`.

let build_submission_result = self.build_submission();
self.flushed.store(true, Ordering::SeqCst);

if let &Err(FlushError::FullScreenExclusiveLost) = &build_submission_result {
self.swapchain
Expand All @@ -1827,7 +1828,6 @@ where
_ => unreachable!(),
}

self.flushed.store(true, Ordering::SeqCst);
Ok(())
}
}
Expand Down Expand Up @@ -1905,18 +1905,16 @@ where
{
fn drop(&mut self) {
unsafe {
if !*self.flushed.get_mut() {
// Flushing may fail, that's okay. We will still wait for the queue later, so any
// previous futures that were flushed correctly will still be waited upon.
self.flush().ok();
}

if !*self.finished.get_mut() {
match self.flush() {
Ok(()) => {
// Block until the queue finished.
self.queue().unwrap().wait().unwrap();
self.previous.signal_finished();
}
Err(_) => {
// In case of error we simply do nothing, as there's nothing to do
// anyway.
}
}
// Block until the queue finished.
self.queue().unwrap().wait().unwrap();
self.previous.signal_finished();
}
}
}
Expand Down