asdf
This commit is contained in:
parent
65bae2196a
commit
c20cee38de
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
renderer_macros = { path = "renderer_macros" }
|
||||||
tinyvec = { workspace = true }
|
tinyvec = { workspace = true }
|
||||||
arrayvec = { workspace = true }
|
arrayvec = { workspace = true }
|
||||||
indexmap = { workspace = true }
|
indexmap = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ name = "renderer_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
|
syn = "2"
|
||||||
|
|
|
||||||
|
|
@ -858,16 +858,17 @@ pub(crate) mod asdf {
|
||||||
};
|
};
|
||||||
|
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
|
use ash::vk::Handle;
|
||||||
|
|
||||||
use crate::{device::DeviceInner, util::DebugName};
|
use crate::{device::DeviceInner, util::DebugName};
|
||||||
|
|
||||||
pub mod traits {
|
pub mod traits {
|
||||||
/// A trait describing an object owned by some manager-type, which is
|
/// A trait describing an object owned by some manager-type, which is
|
||||||
/// responsible for destroying it.
|
/// responsible for destroying it.
|
||||||
pub trait ExternallyManagedObject<T> {
|
pub trait ExternallyManagedObject<Owner> {
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// The caller must ensure this function is only called once for a given object.
|
/// The caller must ensure this function is only called once for a given object.
|
||||||
unsafe fn destroy(self, owner: &T);
|
unsafe fn destroy(self, owner: &Owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait describing an object which can have a debug name assigned to it.
|
/// A trait describing an object which can have a debug name assigned to it.
|
||||||
|
|
@ -1043,6 +1044,29 @@ pub(crate) mod asdf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T, O> std::fmt::Debug for DeviceObject<T, O>
|
||||||
|
where
|
||||||
|
T: std::fmt::Debug + traits::ExternallyManagedObject<O>,
|
||||||
|
O: AsRef<super::DeviceInner>,
|
||||||
|
{
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
let mut fmt = f.debug_struct(core::any::type_name::<T>());
|
||||||
|
let inner: &T = &self.inner;
|
||||||
|
|
||||||
|
fmt.field_with("device", |f| {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"0x{:x}",
|
||||||
|
self.inner.owner().as_ref().raw.handle().as_raw()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.field_with("handle", |f| write!(f, "{inner:?}"))
|
||||||
|
.field("name", &self.name);
|
||||||
|
|
||||||
|
fmt.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T, O> Deref for DeviceObject<T, O>
|
impl<T, O> Deref for DeviceObject<T, O>
|
||||||
where
|
where
|
||||||
T: traits::ExternallyManagedObject<O>,
|
T: traits::ExternallyManagedObject<O>,
|
||||||
|
|
@ -1051,7 +1075,7 @@ pub(crate) mod asdf {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&*self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1061,7 +1085,7 @@ pub(crate) mod asdf {
|
||||||
O: AsRef<super::DeviceInner>,
|
O: AsRef<super::DeviceInner>,
|
||||||
{
|
{
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut *self.inner
|
&mut self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue