Fix panic in surface cleanup

This commit is contained in:
Dzmitry Malyshau authored and Dzmitry Malyshau committed 2021-08-13 02:09:43 -04:00
1 parent f2a18ee57c
commit 450defb743
2 files changed
+14

No files matched your search

+8
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);
+6
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")]