Skip to content

Commit b596ed7

Browse files
committed
adds macos explicity CPU/GPU sync
1 parent 4525ba3 commit b596ed7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bin/23_images.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,10 @@ impl HelloTriangleApplication {
748748

749749
let command_buffer = self.command_buffers[image_index].clone();
750750

751+
// we're joining on the previous future but the CPU is running faster than the GPU so
752+
// eventually it stutters, and jumps ahead to the newer frames.
753+
//
754+
// See vulkano issue 1135: https://github.com/vulkano-rs/vulkano/issues/1135
751755
let future = self.previous_frame_end.take().unwrap()
752756
.join(acquire_future)
753757
.then_execute(self.graphics_queue.clone(), command_buffer)
@@ -757,6 +761,11 @@ impl HelloTriangleApplication {
757761

758762
match future {
759763
Ok(future) => {
764+
// This makes sure the CPU stays in sync with the GPU in situations when the CPU is
765+
// running "too fast"
766+
#[cfg(target_os = "macos")]
767+
future.wait(None).unwrap();
768+
760769
self.previous_frame_end = Some(Box::new(future) as Box<_>);
761770
}
762771
Err(vulkano::sync::FlushError::OutOfDate) => {

0 commit comments

Comments
 (0)