Struct QualiaSlabAllocator
pub struct QualiaSlabAllocator {
pub topology: MemoryTopology,
/* private fields */
}Expand description
A topology-aware ring buffer designed to eliminate heap allocations during hot-path kernel dispatch. Maintains strict bounds invariant so the write_head never laps the read_head.
Every allocation’s start offset is rounded up to alignment bytes so the
resulting BufferView can be used directly as a wgpu bind-group entry
without violating min_{storage,uniform}_buffer_offset_alignment.
Fields§
§topology: MemoryTopologyImplementations§
§impl QualiaSlabAllocator
impl QualiaSlabAllocator
pub fn new(
topology: MemoryTopology,
capacity_bytes: usize,
) -> QualiaSlabAllocator
pub fn new( topology: MemoryTopology, capacity_bytes: usize, ) -> QualiaSlabAllocator
Creates a default QualiaSlabAllocator.
pub fn new_with_alignment(
topology: MemoryTopology,
capacity_bytes: usize,
alignment: usize,
) -> QualiaSlabAllocator
pub fn new_with_alignment( topology: MemoryTopology, capacity_bytes: usize, alignment: usize, ) -> QualiaSlabAllocator
Constructs an allocator with an explicit binding alignment. The usable
capacity is floored to a multiple of alignment so that wrapped offsets
(computed modulo the capacity) remain aligned.
pub fn allocate_transient(
&mut self,
size_bytes: usize,
binding: u32,
group: u32,
usage: BindingUsage,
) -> Result<BufferView, ForgeError>
pub fn allocate_transient( &mut self, size_bytes: usize, binding: u32, group: u32, usage: BindingUsage, ) -> Result<BufferView, ForgeError>
Allocates a transient memory slice within the slab.
The start offset is aligned up to the binding alignment. The allocator bumps the write_count past any alignment/wrap padding plus the size. If the end of the slab is reached, it wraps around to 0 (itself aligned). If the new allocation would lap the read_count, it returns an error.
pub fn advance_read_head(&mut self, new_head_offset: usize)
pub fn advance_read_head(&mut self, new_head_offset: usize)
Advances the read head to free up space. This should be called after a device synchronization fence guarantees the buffer region is no longer in flight.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clears all allocations, resetting the read head to the write head. MUST only be called when all device operations are fully synchronized and complete.
pub fn write_checkpoint(&self) -> u64
pub fn write_checkpoint(&self) -> u64
Snapshot of the write cursor (absolute, not modulo capacity).
pub fn restore_checkpoint(&mut self, write_count: u64)
pub fn restore_checkpoint(&mut self, write_count: u64)
Rewind write/read heads to a prior checkpoint so later transient allocations reuse the same slab region without overwriting earlier persistent views (device bytes below the checkpoint remain intact). Sync before calling.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QualiaSlabAllocator
impl RefUnwindSafe for QualiaSlabAllocator
impl Send for QualiaSlabAllocator
impl Sync for QualiaSlabAllocator
impl Unpin for QualiaSlabAllocator
impl UnsafeUnpin for QualiaSlabAllocator
impl UnwindSafe for QualiaSlabAllocator
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more