deviceowned Eq trait

This commit is contained in:
Janis 2025-01-05 01:13:12 +01:00
parent 32ce6e9140
commit 66ae2603e6
3 changed files with 21 additions and 0 deletions

View file

@ -73,6 +73,13 @@ define_device_owned_handle! {
} }
} }
impl Eq for Buffer {}
impl PartialEq for Buffer {
fn eq(&self, other: &Self) -> bool {
self.inner == other.inner
}
}
impl Buffer { impl Buffer {
pub fn new(device: Device, desc: BufferDesc) -> VkResult<Self> { pub fn new(device: Device, desc: BufferDesc) -> VkResult<Self> {
let queue_families = device.queue_families().family_indices(desc.queue_families); let queue_families = device.queue_families().family_indices(desc.queue_families);

View file

@ -337,6 +337,13 @@ pub struct DeviceOwnedDebugObject<T> {
name: Option<Cow<'static, str>>, name: Option<Cow<'static, str>>,
} }
impl<T: Eq> Eq for DeviceOwnedDebugObject<T> {}
impl<T: PartialEq> PartialEq for DeviceOwnedDebugObject<T> {
fn eq(&self, other: &Self) -> bool {
std::sync::Arc::ptr_eq(&self.device.0, &other.device.0) && self.object == other.object
}
}
impl<T: std::fmt::Debug + vk::Handle + Copy> std::fmt::Debug for DeviceOwnedDebugObject<T> { impl<T: std::fmt::Debug + vk::Handle + Copy> std::fmt::Debug for DeviceOwnedDebugObject<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut fmt = f.debug_struct(core::any::type_name::<T>()); let mut fmt = f.debug_struct(core::any::type_name::<T>());

View file

@ -143,6 +143,13 @@ define_device_owned_handle! {
} }
} }
impl Eq for Image {}
impl PartialEq for Image {
fn eq(&self, other: &Self) -> bool {
self.inner == other.inner
}
}
impl Image { impl Image {
pub fn new(device: Device, desc: ImageDesc) -> VkResult<Self> { pub fn new(device: Device, desc: ImageDesc) -> VkResult<Self> {
let ImageDesc { let ImageDesc {