From 5fc4830fb875ee6c8ec932088ef17f6b7130d349 Mon Sep 17 00:00:00 2001 From: Matthew Russo Date: Sun, 24 Feb 2019 21:23:24 -0500 Subject: [PATCH] adds macos explicity CPU/GPU sync --- src/bin/28_generating_mipmaps.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bin/28_generating_mipmaps.rs b/src/bin/28_generating_mipmaps.rs index e0a64bc..41572ae 100644 --- a/src/bin/28_generating_mipmaps.rs +++ b/src/bin/28_generating_mipmaps.rs @@ -919,6 +919,10 @@ impl HelloTriangleApplication { let command_buffer = self.command_buffers[image_index].clone(); + // we're joining on the previous future but the CPU is running faster than the GPU so + // eventually it stutters, and jumps ahead to the newer frames. + // + // See vulkano issue 1135: https://github.com/vulkano-rs/vulkano/issues/1135 let future = self.previous_frame_end.take().unwrap() .join(acquire_future) .then_execute(self.graphics_queue.clone(), command_buffer) @@ -928,6 +932,11 @@ impl HelloTriangleApplication { match future { Ok(future) => { + // This makes sure the CPU stays in sync with the GPU in situations when the CPU is + // running "too fast" + #[cfg(target_os = "macos")] + future.wait(None).unwrap(); + self.previous_frame_end = Some(Box::new(future) as Box<_>); } Err(vulkano::sync::FlushError::OutOfDate) => {