mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 06:45:23 +00:00
Merge pull request #551 from tomaka/acquire-sc-timeout
The timeout of acquire_next_image is now optional
This commit is contained in:
commit
d7c9d08f76
@ -154,7 +154,7 @@ fn main() {
|
||||
loop {
|
||||
previous_frame_end.cleanup_finished();
|
||||
|
||||
let (image_num, future) = vulkano::swapchain::acquire_next_image(swapchain.clone(), Duration::new(10, 0)).unwrap();
|
||||
let (image_num, future) = vulkano::swapchain::acquire_next_image(swapchain.clone(), None).unwrap();
|
||||
|
||||
let cb = vulkano::command_buffer::AutoCommandBufferBuilder::new(device.clone(), queue.family())
|
||||
.unwrap()
|
||||
|
@ -166,7 +166,7 @@ fn main() {
|
||||
buffer_content.world = cgmath::Matrix4::from(rotation).into();
|
||||
}
|
||||
|
||||
let (image_num, acquire_future) = vulkano::swapchain::acquire_next_image(swapchain.clone(), std::time::Duration::new(1, 0)).unwrap();
|
||||
let (image_num, acquire_future) = vulkano::swapchain::acquire_next_image(swapchain.clone(), None).unwrap();
|
||||
|
||||
let command_buffer = vulkano::command_buffer::AutoCommandBufferBuilder::new(device.clone(), queue.family()).unwrap()
|
||||
.begin_render_pass(
|
||||
|
@ -329,10 +329,10 @@ void main() {
|
||||
// function will block.
|
||||
// This operation returns the index of the image that we are allowed to draw upon.
|
||||
//
|
||||
// This function can block if no image is available. The parameter is a timeout after
|
||||
// which the function call will return an error.
|
||||
// This function can block if no image is available. The parameter is an optional timeout
|
||||
// after which the function call will return an error.
|
||||
let (image_num, acquire_future) = swapchain::acquire_next_image(swapchain.clone(),
|
||||
Duration::new(1, 0)).unwrap();
|
||||
None).unwrap();
|
||||
|
||||
// In order to draw, we have to build a *command buffer*. The command buffer object holds
|
||||
// the list of commands that are going to be executed.
|
||||
|
@ -136,7 +136,7 @@
|
||||
//!
|
||||
//! TODO: add example here
|
||||
//! loop {
|
||||
//! let index = swapchain::acquire_next_image(Duration::from_millis(500)).unwrap();
|
||||
//! let index = swapchain::acquire_next_image(None).unwrap();
|
||||
//! draw(images[index]);
|
||||
//! swapchain::present(queue, index).unwrap();
|
||||
//! }
|
||||
@ -173,7 +173,7 @@
|
||||
//!
|
||||
//! let (ref swapchain, ref _images) = swapchain;
|
||||
//!
|
||||
//! let (index, acq_future) = match swapchain::acquire_next_image(swapchain.clone(), Duration::from_millis(500)) {
|
||||
//! let (index, acq_future) = match swapchain::acquire_next_image(swapchain.clone(), None) {
|
||||
//! Ok(r) => r,
|
||||
//! Err(AcquireError::OutOfDate) => { recreate_swapchain = true; continue; },
|
||||
//! Err(err) => panic!("{:?}", err)
|
||||
|
@ -65,8 +65,7 @@ use vk;
|
||||
/// behavior may change).
|
||||
// TODO: has to make sure vkQueuePresent is called, because calling acquire_next_image many
|
||||
// times in a row is an error
|
||||
// TODO: change timeout to `Option<Duration>`.
|
||||
pub fn acquire_next_image(swapchain: Arc<Swapchain>, timeout: Duration)
|
||||
pub fn acquire_next_image(swapchain: Arc<Swapchain>, timeout: Option<Duration>)
|
||||
-> Result<(usize, SwapchainAcquireFuture), AcquireError>
|
||||
{
|
||||
unsafe {
|
||||
@ -82,8 +81,12 @@ pub fn acquire_next_image(swapchain: Arc<Swapchain>, timeout: Duration)
|
||||
|
||||
let semaphore = try!(Semaphore::new(swapchain.device.clone()));
|
||||
|
||||
let timeout_ns = timeout.as_secs().saturating_mul(1_000_000_000)
|
||||
.saturating_add(timeout.subsec_nanos() as u64);
|
||||
let timeout_ns = if let Some(timeout) = timeout {
|
||||
timeout.as_secs().saturating_mul(1_000_000_000)
|
||||
.saturating_add(timeout.subsec_nanos() as u64)
|
||||
} else {
|
||||
u64::max_value()
|
||||
};
|
||||
|
||||
let mut out = mem::uninitialized();
|
||||
let r = try!(check_errors(vk.AcquireNextImageKHR(swapchain.device.internal_object(),
|
||||
|
Loading…
Reference in New Issue
Block a user