Skip to content

Commit

Permalink
adds macos explicity CPU/GPU sync
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-russo committed Feb 25, 2019
1 parent 226f4eb commit 5fc4830
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bin/28_generating_mipmaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) => {
Expand Down

0 comments on commit 5fc4830

Please sign in to comment.