Fix panic in surface cleanup

This commit is contained in:
Dzmitry Malyshau
2021-08-13 00:13:29 -04:00
committed by Dzmitry Malyshau
parent f2a18ee57c
commit 450defb743
2 changed files with 14 additions and 0 deletions

View File

@@ -724,6 +724,14 @@ impl<A: HalApi, F: GlobalIdentityHandlerFactory> Hub<A, F> {
for element in surface_guard.map.iter_mut() {
if let Element::Occupied(ref mut surface, _epoch) = *element {
if surface
.presentation
.as_ref()
.map_or(wgt::Backend::Empty, |p| p.backend())
!= A::VARIANT
{
continue;
}
if let Some(present) = surface.presentation.take() {
let device = &devices[present.device_id.value];
let suf = A::get_surface_mut(surface);

View File

@@ -36,6 +36,12 @@ pub(crate) struct Presentation {
pub(crate) acquired_texture: Option<Stored<TextureId>>,
}
impl Presentation {
pub(crate) fn backend(&self) -> wgt::Backend {
crate::id::TypedId::unzip(self.device_id.value.0).2
}
}
#[derive(Clone, Debug, Error)]
pub enum SurfaceError {
#[error("surface is invalid")]