Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround moltenvk problems in examples. #1027

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/src/bin/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ fn main() {

match future {
Ok(future) => {
if cfg!(target_os = "macos") {
// Workaround for moltenvk issue (hang on close)
// FIXME Remove once motenvk is fixed
future.wait(None).expect("waiting on fence failed");
}
previous_frame_end = Box::new(future) as Box<_>;
}
Err(vulkano::sync::FlushError::OutOfDate) => {
Expand Down
11 changes: 8 additions & 3 deletions examples/src/bin/teapot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn main() {
dimensions = surface.capabilities(physical)
.expect("failed to get surface capabilities")
.current_extent.unwrap_or([1024, 768]);

let (new_swapchain, new_images) = match swapchain.recreate_with_dimension(dimensions) {
Ok(r) => r,
Err(vulkano::swapchain::SwapchainCreationError::UnsupportedDimensions) => {
Expand Down Expand Up @@ -231,18 +231,23 @@ fn main() {
.draw_indexed(
pipeline.clone(),
&dynamic_state,
(vertex_buffer.clone(), normals_buffer.clone()),
(vertex_buffer.clone(), normals_buffer.clone()),
index_buffer.clone(), set.clone(), ()).unwrap()
.end_render_pass().unwrap()
.build().unwrap();

let future = previous_frame.join(acquire_future)
.then_execute(queue.clone(), command_buffer).unwrap()
.then_swapchain_present(queue.clone(), swapchain.clone(), image_num)
.then_signal_fence_and_flush();

match future {
Ok(future) => {
if cfg!(target_os = "macos") {
// Workaround for moltenvk issue (hang on close)
// FIXME Remove once motenvk is fixed
future.wait(None).expect("waiting on fence failed");
}
previous_frame = Box::new(future) as Box<_>;
}
Err(vulkano::sync::FlushError::OutOfDate) => {
Expand Down
10 changes: 10 additions & 0 deletions examples/src/bin/tessellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ fn main() {
.next().expect("no device available");
println!("Using device: {} (type: {:?})", physical.name(), physical.ty());

if !physical.supported_features().tessellation_shader {
println!("Tessellation shaders not supported on physical device");
return;
}

let mut events_loop = winit::EventsLoop::new();
let surface = winit::WindowBuilder::new().build_vk_surface(&events_loop, instance.clone()).unwrap();

Expand Down Expand Up @@ -322,6 +327,11 @@ void main() {

match future {
Ok(future) => {
if cfg!(target_os = "macos") {
// Workaround for moltenvk issue (hang on close)
// FIXME Remove once motenvk is fixed
future.wait(None).expect("waiting on fence failed");
}
previous_frame_end = Box::new(future) as Box<_>;
}
Err(vulkano::sync::FlushError::OutOfDate) => {
Expand Down
11 changes: 8 additions & 3 deletions examples/src/bin/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn main() {
// window and a cross-platform Vulkan surface that represents the surface of the window.
let mut events_loop = winit::EventsLoop::new();
let surface = winit::WindowBuilder::new().build_vk_surface(&events_loop, instance.clone()).unwrap();

// The next step is to choose which GPU queue will execute our draw commands.
//
// Devices can provide multiple queues to run commands in parallel (for example a draw queue
Expand Down Expand Up @@ -166,7 +166,7 @@ fn main() {
// pass values that are allowed by the capabilities.
let caps = surface.capabilities(physical)
.expect("failed to get surface capabilities");

dimensions = caps.current_extent.unwrap_or([1024, 768]);

// We choose the dimensions of the swapchain to match the current extent of the surface.
Expand Down Expand Up @@ -352,7 +352,7 @@ void main() {
dimensions = surface.capabilities(physical)
.expect("failed to get surface capabilities")
.current_extent.unwrap();

let (new_swapchain, new_images) = match swapchain.recreate_with_dimension(dimensions) {
Ok(r) => r,
// This error tends to happen when the user is manually resizing the window.
Expand Down Expand Up @@ -457,6 +457,11 @@ void main() {

match future {
Ok(future) => {
if cfg!(target_os = "macos") {
// Workaround for moltenvk issue (hang on close)
// FIXME Remove once motenvk is fixed
future.wait(None).expect("waiting on fence failed");
}
previous_frame_end = Box::new(future) as Box<_>;
}
Err(vulkano::sync::FlushError::OutOfDate) => {
Expand Down