Merge pull request #3067 from camspiers/fixes/surface-outdated
Reconfigure wgpu surface on SurfaceError Lost or Outdated
This commit is contained in:
commit
1cde186def
1 changed files with 26 additions and 1 deletions
|
|
@ -1009,10 +1009,35 @@ async fn run_instance<P>(
|
||||||
present_span.finish();
|
present_span.finish();
|
||||||
}
|
}
|
||||||
Err(error) => match error {
|
Err(error) => match error {
|
||||||
// This is an unrecoverable error.
|
|
||||||
compositor::SurfaceError::OutOfMemory => {
|
compositor::SurfaceError::OutOfMemory => {
|
||||||
|
// This is an unrecoverable error.
|
||||||
panic!("{error:?}");
|
panic!("{error:?}");
|
||||||
}
|
}
|
||||||
|
compositor::SurfaceError::Outdated
|
||||||
|
| compositor::SurfaceError::Lost => {
|
||||||
|
present_span.finish();
|
||||||
|
|
||||||
|
// Reconfigure surface and try redrawing
|
||||||
|
let physical_size =
|
||||||
|
window.state.physical_size();
|
||||||
|
|
||||||
|
if error == compositor::SurfaceError::Lost {
|
||||||
|
window.surface = current_compositor
|
||||||
|
.create_surface(
|
||||||
|
window.raw.clone(),
|
||||||
|
physical_size.width,
|
||||||
|
physical_size.height,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
current_compositor.configure_surface(
|
||||||
|
&mut window.surface,
|
||||||
|
physical_size.width,
|
||||||
|
physical_size.height,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.raw.request_redraw();
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
present_span.finish();
|
present_span.finish();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue