use serde::{Deserialize, Serialize};
macro_rules! id_type {
($name:ident, $doc:literal) => {
#[doc = $doc]
#[derive(
Copy,
Clone,
Debug,
Default,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
Serialize,
Deserialize,
)]
#[serde(transparent)]
pub struct $name(pub u64);
impl $name {
pub fn get(self) -> u64 {
self.0
}
}
impl From<u64> for $name {
fn from(v: u64) -> Self {
$name(v)
}
}
impl From<$name> for u64 {
fn from(v: $name) -> Self {
v.0
}
}
};
}
id_type!(Seq, "Global monotonic event sequence number within a trace session.");
id_type!(RequestId, "Correlation id for a logical request (an asset load, a frame, ...).");
id_type!(SpanId, "Id of a begin/end span (pair of events).");
id_type!(FileKey, "Hash of a file identity (path or object id).");
id_type!(Epoch, "Lifetime/recycling epoch. Higher = later.");
id_type!(OpId, "Id of an in-flight I/O or asynchronous operation.");
id_type!(AllocId, "Id of an allocation in a staging arena.");
id_type!(ArenaId, "Id of a staging arena.");
pub type ResourceRef = (u32, u64);
pub mod resource_domain {
pub const FILE: u32 = 1;
pub const D3D12_RESOURCE: u32 = 2;
pub const D3D12_QUEUE: u32 = 3;
pub const VK_OBJECT: u32 = 4;
pub const KATRA_ARENA: u32 = 5;
pub const DESCRIPTOR_HEAP: u32 = 6;
pub const PIPELINE: u32 = 7;
pub const FENCE: u32 = 8;
}