diff --git a/ash/src/extensions/swapchain.rs b/ash/src/extensions/swapchain.rs index 0a99708..8d630ef 100644 --- a/ash/src/extensions/swapchain.rs +++ b/ash/src/extensions/swapchain.rs @@ -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 { + ) -> VkResult<(u32, bool)> { let mut index = mem::uninitialized(); let err_code = self.swapchain_fn.acquire_next_image_khr( self.handle, @@ -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), } } @@ -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 { 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), } } diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index d87df89..1381e82 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -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, diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index 12a3b85..f2f467b 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -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,