Merge pull request #667 from BillyDM/wgpu_outdatedframe

Don't panic when wgpu swapchain frame is outdated
This commit is contained in:
Héctor Ramón 2021-08-05 14:44:32 +07:00 committed by GitHub
commit 45778ed598
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 180 additions and 109 deletions

View file

@ -366,27 +366,43 @@ async fn run_instance<A, E, C>(
viewport_version = current_viewport_version;
}
let new_mouse_interaction = compositor.draw(
match compositor.draw(
&mut renderer,
&mut swap_chain,
state.viewport(),
state.background_color(),
&primitive,
&debug.overlay(),
);
) {
Ok(new_mouse_interaction) => {
debug.render_finished();
debug.render_finished();
if new_mouse_interaction != mouse_interaction {
window.set_cursor_icon(
conversion::mouse_interaction(
new_mouse_interaction,
),
);
if new_mouse_interaction != mouse_interaction {
window.set_cursor_icon(conversion::mouse_interaction(
new_mouse_interaction,
));
mouse_interaction = new_mouse_interaction;
}
mouse_interaction = new_mouse_interaction;
// TODO: Handle animations!
// Maybe we can use `ControlFlow::WaitUntil` for this.
}
Err(error) => match error {
// This is an unrecoverable error.
window::SwapChainError::OutOfMemory => {
panic!("{}", error);
}
_ => {
debug.render_finished();
// Try rendering again next frame.
window.request_redraw();
}
},
}
// TODO: Handle animations!
// Maybe we can use `ControlFlow::WaitUntil` for this.
}
event::Event::WindowEvent {
event: event::WindowEvent::MenuEntryActivated(entry_id),