This commit is contained in:
janis 2026-04-04 16:24:36 +02:00
parent 44ff4c4839
commit cf7f5152bc

View file

@ -481,6 +481,16 @@ impl core::ops::Deref for Device {
}
}
impl<T> AsRef<T> for Device
where
T: ?Sized,
<Self as Deref>::Target: AsRef<T>,
{
fn as_ref(&self) -> &T {
self.deref().as_ref()
}
}
impl DeviceInner {
pub fn sync_threadpool(&self) -> &sync::SyncThreadpool {
&self.sync_threadpool
@ -749,6 +759,8 @@ impl<T: DeviceHandle> Drop for DeviceObject<T> {
}
pub trait DeviceHandle {
/// # Safety
/// The caller must ensure this function is only called once for a given object.
unsafe fn destroy(&mut self, device: &Device);
}
@ -779,11 +791,9 @@ impl DeviceHandle for vk::Buffer {
impl DeviceHandle for vk::SwapchainKHR {
unsafe fn destroy(&mut self, device: &Device) {
unsafe {
device
.device_extensions
.swapchain
.as_ref()
.map(|swapchain| swapchain.destroy_swapchain(*self, None));
if let Some(swapchain) = device.device_extensions.swapchain.as_ref() {
swapchain.destroy_swapchain(*self, None)
}
}
}
}