Skip to content

Commit

Permalink
alt/vk: destroy swapchain on drop
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Jul 31, 2019
1 parent 1ece246 commit 814546a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/backend/vulkan/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ impl Surface {
}
}

impl Drop for Surface {
fn drop(&mut self) {
if let Some(ssc) = self.swapchain.take() {
use ash::version::DeviceV1_0;
unsafe {
let _ = ssc.device.0.device_wait_idle();
ssc.device.0.destroy_fence(ssc.fence.0, None);
ssc.swapchain.functor.destroy_swapchain(ssc.swapchain.raw, None);
}
};
self.clear_stale_views();
}
}

pub struct RawSurface {
pub(crate) handle: vk::SurfaceKHR,
functor: khr::Surface,
Expand Down

0 comments on commit 814546a

Please sign in to comment.