This commit is contained in:
janis 2026-04-11 00:48:04 +02:00
parent 4f95f3a928
commit 3a39d8dc96
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8

View file

@ -4,7 +4,6 @@ use ash::{ext, prelude::*, vk};
use parking_lot::Mutex;
use crate::{
define_device_owned_handle,
device::{
Device, DeviceHandle, DeviceInner, DeviceObject, asdf::traits::ExternallyManagedObject,
},
@ -450,12 +449,21 @@ impl std::hash::Hash for SamplerDesc {
}
}
define_device_owned_handle! {
#[derive(Debug)]
pub Sampler(vk::Sampler) {} => |this| unsafe {
this.device().dev().destroy_sampler(this.handle(), None);
impl<T> ExternallyManagedObject<T> for vk::Sampler
where
T: AsRef<DeviceInner>,
{
unsafe fn destroy(self, device: &T) {
unsafe {
device.as_ref().raw.destroy_sampler(self, None);
}
}
}
#[derive(Debug)]
pub struct Sampler {
sampler: DeviceObject<vk::Sampler>,
}
impl Sampler {
pub fn new(device: Device, desc: &SamplerDesc) -> VkResult<Self> {
@ -479,7 +487,9 @@ impl Sampler {
let handle = unsafe { device.dev().create_sampler(info, None)? };
Self::construct(device, handle, None)
Ok(Self {
sampler: DeviceObject::new(device, handle),
})
}
}