diff --git a/src/graphics.rs b/src/graphics.rs index aad104d..362ce5f 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -65,6 +65,22 @@ impl<'window> Gpu<'window> { let surface = instance.create_surface(Arc::clone(&window)).unwrap(); let push_const_size = std::mem::size_of::<[f32; 2]>() as u32; + // Jitter when resizing windows on macOS + // https://github.com/gfx-rs/wgpu/issues/3756 + // https://github.com/gfx-rs/wgpu/pull/6107 + // https://thume.ca/2019/06/19/glitchless-metal-window-resizing/ + // https://raphlinus.github.io/rust/gui/2019/06/21/smooth-resize-test.html + #[allow(invalid_reference_casting)] + unsafe { + surface.as_hal::(|surface| { + if let Some(surface_ref) = surface { + let surface_mut = &mut *(surface_ref as *const wgpu::hal::metal::Surface + as *mut wgpu::hal::metal::Surface); + surface_mut.present_with_transaction = true; + } + }); + } + let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::default(),