Skip to content

Commit

Permalink
Expose suboptimal results from swapchain operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Oct 7, 2018
1 parent c62172b commit ffa09c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions ash/src/extensions/swapchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ impl Swapchain {
);
}

/// On success, returns the next image's index and whether the swapchain is suboptimal for the surface.
pub unsafe fn acquire_next_image_khr(
&self,
swapchain: vk::SwapchainKHR,
timeout: u64,
semaphore: vk::Semaphore,
fence: vk::Fence,
) -> VkResult<u32> {
) -> VkResult<(u32, bool)> {
let mut index = mem::uninitialized();
let err_code = self.swapchain_fn.acquire_next_image_khr(
self.handle,
Expand All @@ -60,7 +61,8 @@ impl Swapchain {
&mut index,
);
match err_code {
vk::Result::SUCCESS => Ok(index),
vk::Result::SUCCESS => Ok((index, false)),
vk::Result::SUBOPTIMAL_KHR => Ok((index, true)),
_ => Err(err_code),
}
}
Expand All @@ -83,14 +85,16 @@ impl Swapchain {
}
}

/// On success, returns whether the swapchain is suboptimal for the surface.
pub unsafe fn queue_present_khr(
&self,
queue: vk::Queue,
create_info: &vk::PresentInfoKHR,
) -> VkResult<()> {
) -> VkResult<bool> {
let err_code = self.swapchain_fn.queue_present_khr(queue, create_info);
match err_code {
vk::Result::SUCCESS => Ok(()),
vk::Result::SUCCESS => Ok(false),
vk::Result::SUBOPTIMAL_KHR => Ok(true),
_ => Err(err_code),
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ fn main() {
let graphic_pipeline = graphics_pipelines[0];

base.render_loop(|| {
let present_index = base
let (present_index, _) = base
.swapchain_loader
.acquire_next_image_khr(
base.swapchain,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ fn main() {
let graphic_pipeline = graphics_pipelines[0];

base.render_loop(|| {
let present_index = base
let (present_index, _) = base
.swapchain_loader
.acquire_next_image_khr(
base.swapchain,
Expand Down

0 comments on commit ffa09c5

Please sign in to comment.