#[derive(Debug, Copy, Clone)]
pub struct LockRank {
pub(super) bit: LockRankSet,
pub(super) followers: LockRankSet,
}
macro_rules! define_lock_ranks {
{
$(
$( #[ $attr:meta ] )*
rank $name:ident $member:literal followed by { $( $follower:ident ),* $(,)? }
)*
} => {
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
enum LockRankNumber { $( $name, )* }
bitflags::bitflags! {
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct LockRankSet: u64 {
$(
const $name = 1 << (LockRankNumber:: $name as u64);
)*
}
}
impl LockRankSet {
pub fn member_name(self) -> &'static str {
match self {
$(
LockRankSet:: $name => $member,
)*
_ => "<unrecognized LockRankSet bit>",
}
}
#[cfg_attr(not(feature = "observe_locks"), allow(dead_code))]
pub fn const_name(self) -> &'static str {
match self {
$(
LockRankSet:: $name => stringify!($name),
)*
_ => "<unrecognized LockRankSet bit>",
}
}
}
$(
$( #[ $attr ] )*
pub const $name: LockRank = LockRank {
bit: LockRankSet:: $name,
followers: LockRankSet::empty() $( .union($follower.bit) )*,
};
)*
}
}
define_lock_ranks! {
rank COMMAND_BUFFER_DATA "CommandBuffer::data" followed by {
DEVICE_SNATCHABLE_LOCK,
DEVICE_USAGE_SCOPES,
SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
BUFFER_MAP_STATE,
}
rank DEVICE_SNATCHABLE_LOCK "Device::snatchable_lock" followed by {
SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
DEVICE_TRACE,
BUFFER_MAP_STATE,
}
rank BUFFER_MAP_STATE "Buffer::map_state" followed by {
QUEUE_PENDING_WRITES,
SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
DEVICE_TRACE,
}
rank QUEUE_PENDING_WRITES "Queue::pending_writes" followed by {
COMMAND_ALLOCATOR_FREE_ENCODERS,
SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
QUEUE_LIFE_TRACKER,
}
rank QUEUE_LIFE_TRACKER "Queue::life_tracker" followed by {
COMMAND_ALLOCATOR_FREE_ENCODERS,
DEVICE_TRACE,
}
rank COMMAND_ALLOCATOR_FREE_ENCODERS "CommandAllocator::free_encoders" followed by {
SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
}
rank BUFFER_BIND_GROUPS "Buffer::bind_groups" followed by { }
rank BUFFER_INITIALIZATION_STATUS "Buffer::initialization_status" followed by { }
rank DEVICE_DEFERRED_DESTROY "Device::deferred_destroy" followed by { }
rank DEVICE_FENCE "Device::fence" followed by { }
#[allow(dead_code)]
rank DEVICE_TRACE "Device::trace" followed by { }
rank DEVICE_TRACKERS "Device::trackers" followed by { }
rank DEVICE_LOST_CLOSURE "Device::device_lost_closure" followed by { }
rank DEVICE_USAGE_SCOPES "Device::usage_scopes" followed by { }
rank IDENTITY_MANAGER_VALUES "IdentityManager::values" followed by { }
rank REGISTRY_STORAGE "Registry::storage" followed by { }
rank RESOURCE_POOL_INNER "ResourcePool::inner" followed by { }
rank SHARED_TRACKER_INDEX_ALLOCATOR_INNER "SharedTrackerIndexAllocator::inner" followed by { }
rank SURFACE_PRESENTATION "Surface::presentation" followed by { }
rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { }
rank TEXTURE_INITIALIZATION_STATUS "Texture::initialization_status" followed by { }
rank TEXTURE_VIEWS "Texture::views" followed by { }
rank BLAS_BUILT_INDEX "Blas::built_index" followed by { }
rank TLAS_BUILT_INDEX "Tlas::built_index" followed by { }
rank TLAS_DEPENDENCIES "Tlas::dependencies" followed by { }
rank TLAS_BIND_GROUPS "Tlas::bind_groups" followed by { }
#[cfg(test)]
rank PAWN "pawn" followed by { ROOK, BISHOP }
#[cfg(test)]
rank ROOK "rook" followed by { KNIGHT }
#[cfg(test)]
rank KNIGHT "knight" followed by { }
#[cfg(test)]
rank BISHOP "bishop" followed by { }
}