Skip to content

Commit

Permalink
Postpone call to get_current_texture
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 29, 2024
1 parent 1d1b07c commit 51371be
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions crates/egui-wgpu/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 51371be

Please sign in to comment.