diff --git a/piet-gpu/bin/winit.rs b/piet-gpu/bin/winit.rs index c5f9bef..19db3c2 100644 --- a/piet-gpu/bin/winit.rs +++ b/piet-gpu/bin/winit.rs @@ -1,4 +1,3 @@ -use piet::RenderContext; use piet_gpu_hal::{Error, ImageLayout, Instance, Session, SubmittedCmdBuf}; use piet_gpu::{test_scenes, PietGpuRenderContext, Renderer}; @@ -152,6 +151,13 @@ fn main() -> Result<(), Error> { current_frame += 1; } + Event::LoopDestroyed => { + if let Some(submitted) = submitted.take() { + // Wait for command list submission, otherwise dropping of renderer may + // cause validation errors (and possibly crashes). + submitted.wait().unwrap(); + } + } _ => (), } })