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

vk: return dummy swapchain image on OutOfDate #234

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions blade-graphics/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,6 @@ impl crate::traits::CommandEncoder for super::CommandEncoder {
}

fn present(&mut self, frame: super::Frame) {
if frame.internal.acquire_semaphore == vk::Semaphore::null() {
return;
}

assert_eq!(self.present, None);
let wa = &self.device.workarounds;
self.present = Some(super::Presentation {
Expand Down
30 changes: 13 additions & 17 deletions blade-graphics/src/vulkan/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,30 @@ impl super::Surface {

pub fn acquire_frame(&mut self) -> super::Frame {
let acquire_semaphore = self.next_semaphore;
match unsafe {
let index = match unsafe {
self.device.acquire_next_image(
self.swapchain.raw,
!0,
acquire_semaphore,
vk::Fence::null(),
)
} {
Ok((index, _suboptimal)) => {
self.next_semaphore = mem::replace(
&mut self.frames[index as usize].acquire_semaphore,
acquire_semaphore,
);
super::Frame {
internal: self.frames[index as usize],
swapchain: self.swapchain,
image_index: index,
}
}
Ok((index, _suboptimal)) => index,
Err(vk::Result::ERROR_OUT_OF_DATE_KHR) => {
log::warn!("Acquire failed because the surface is out of date");
super::Frame {
internal: super::InternalFrame::default(),
swapchain: self.swapchain,
image_index: 0,
}
0
}
Err(other) => panic!("Aquire image error {}", other),
};

self.next_semaphore = mem::replace(
&mut self.frames[index as usize].acquire_semaphore,
acquire_semaphore,
);
super::Frame {
internal: self.frames[index as usize],
swapchain: self.swapchain,
image_index: index,
}
}
}
Expand Down
Loading