Expose suboptimal results from swapchain operations
This commit is contained in:
parent
c62172bdf8
commit
ffa09c5fd9
|
@ -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(
|
pub unsafe fn acquire_next_image_khr(
|
||||||
&self,
|
&self,
|
||||||
swapchain: vk::SwapchainKHR,
|
swapchain: vk::SwapchainKHR,
|
||||||
timeout: u64,
|
timeout: u64,
|
||||||
semaphore: vk::Semaphore,
|
semaphore: vk::Semaphore,
|
||||||
fence: vk::Fence,
|
fence: vk::Fence,
|
||||||
) -> VkResult<u32> {
|
) -> VkResult<(u32, bool)> {
|
||||||
let mut index = mem::uninitialized();
|
let mut index = mem::uninitialized();
|
||||||
let err_code = self.swapchain_fn.acquire_next_image_khr(
|
let err_code = self.swapchain_fn.acquire_next_image_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
|
@ -60,7 +61,8 @@ impl Swapchain {
|
||||||
&mut index,
|
&mut index,
|
||||||
);
|
);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(index),
|
vk::Result::SUCCESS => Ok((index, false)),
|
||||||
|
vk::Result::SUBOPTIMAL_KHR => Ok((index, true)),
|
||||||
_ => Err(err_code),
|
_ => 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(
|
pub unsafe fn queue_present_khr(
|
||||||
&self,
|
&self,
|
||||||
queue: vk::Queue,
|
queue: vk::Queue,
|
||||||
create_info: &vk::PresentInfoKHR,
|
create_info: &vk::PresentInfoKHR,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<bool> {
|
||||||
let err_code = self.swapchain_fn.queue_present_khr(queue, create_info);
|
let err_code = self.swapchain_fn.queue_present_khr(queue, create_info);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(()),
|
vk::Result::SUCCESS => Ok(false),
|
||||||
|
vk::Result::SUBOPTIMAL_KHR => Ok(true),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -876,7 +876,7 @@ fn main() {
|
||||||
let graphic_pipeline = graphics_pipelines[0];
|
let graphic_pipeline = graphics_pipelines[0];
|
||||||
|
|
||||||
base.render_loop(|| {
|
base.render_loop(|| {
|
||||||
let present_index = base
|
let (present_index, _) = base
|
||||||
.swapchain_loader
|
.swapchain_loader
|
||||||
.acquire_next_image_khr(
|
.acquire_next_image_khr(
|
||||||
base.swapchain,
|
base.swapchain,
|
||||||
|
|
|
@ -461,7 +461,7 @@ fn main() {
|
||||||
let graphic_pipeline = graphics_pipelines[0];
|
let graphic_pipeline = graphics_pipelines[0];
|
||||||
|
|
||||||
base.render_loop(|| {
|
base.render_loop(|| {
|
||||||
let present_index = base
|
let (present_index, _) = base
|
||||||
.swapchain_loader
|
.swapchain_loader
|
||||||
.acquire_next_image_khr(
|
.acquire_next_image_khr(
|
||||||
base.swapchain,
|
base.swapchain,
|
||||||
|
|
Loading…
Reference in a new issue