From 51371bec8df668b33afb272334dd1bc424e53b5a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 29 Jan 2024 16:28:20 +0100 Subject: [PATCH] Postpone call to get_current_texture --- crates/egui-wgpu/src/winit.rs | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/egui-wgpu/src/winit.rs b/crates/egui-wgpu/src/winit.rs index ca292212a15..41e618fd232 100644 --- a/crates/egui-wgpu/src/winit.rs +++ b/crates/egui-wgpu/src/winit.rs @@ -519,25 +519,6 @@ impl Painter { let render_state = self.render_state.as_mut()?; let surface_state = self.surfaces.get(&viewport_id)?; - let output_frame = { - crate::profile_scope!("get_current_texture"); - // This is what vsync-waiting happens, at least on Mac. - surface_state.surface.get_current_texture() - }; - - let output_frame = match output_frame { - Ok(frame) => frame, - Err(err) => match (*self.configuration.on_surface_error)(err) { - SurfaceErrorAction::RecreateSurface => { - Self::configure_surface(surface_state, render_state, &self.configuration); - return None; - } - SurfaceErrorAction::SkipFrame => { - return None; - } - }, - }; - let mut encoder = render_state .device @@ -580,6 +561,25 @@ impl Painter { } }; + let output_frame = { + crate::profile_scope!("get_current_texture"); + // This is what vsync-waiting happens, at least on Mac. + surface_state.surface.get_current_texture() + }; + + let output_frame = match output_frame { + Ok(frame) => frame, + Err(err) => match (*self.configuration.on_surface_error)(err) { + SurfaceErrorAction::RecreateSurface => { + Self::configure_surface(surface_state, render_state, &self.configuration); + return None; + } + SurfaceErrorAction::SkipFrame => { + return None; + } + }, + }; + { let renderer = render_state.renderer.read(); let frame_view = if capture {