Skip to main content

DefragmentationPass

Struct DefragmentationPass 

Source
pub struct DefragmentationPass<'allocator, 'device> { /* private fields */ }
Expand description

Exclusively borrows the allocator while replacement resources are prepared.

Create/bind replacements, copy and complete GPU work, update consumer native references, destroy each old resource, then commit its move. Ignore/abort needs replacement resources destroyed first. finish requires every move resolved. Alias groups additionally require all members recreated and retired together. Source and destination mapping holds stay distinct until resolution. Old source pointers expire on commit; destination pointers expire on ignore/destroy. Drop does no native work: omitting explicit resolution can leak reservations.

Implementations§

Source§

impl DefragmentationPass<'_, '_>

Source

pub fn len(&self) -> usize

Proposed move count, including moves already explicitly resolved.

Source

pub fn is_empty(&self) -> bool

Source

pub fn was_interrupted(&self) -> bool

The stop predicate returned true. An interrupted empty pass does not mean compaction is complete; a later context pass can resume scheduling.

Source

pub fn movement(&self, index: usize) -> Result<&DefragmentationMove, AllocError>

Borrow a proposal’s stable original snapshots; no native ownership is acquired.

Source

pub fn device(&self) -> &Device

Access the same borrowed device for explicit replacement/copy/completion operations.

Source

pub fn allocation_callbacks(&self) -> Option<&AllocationCallbacks>

Retained native callbacks for explicit old/replacement resource destruction.

Source

pub unsafe fn bind_buffer( &mut self, index: usize, buffer: Buffer, ) -> Result<(), AllocError>

Bind a caller-created replacement buffer to this move’s reserved destination.

§Safety

Replacement must satisfy the source requirements and native valid usage; no copy/completion/destruction is performed here.

Source

pub unsafe fn bind_image( &mut self, index: usize, image: Image, ) -> Result<(), AllocError>

Bind a caller-created replacement image to the reserved destination.

§Safety

Caller supplies matching ordinary image requirements/layout/tiling and valid enabled features.

Source

pub unsafe fn create_aliasing_buffer( &mut self, index: usize, local_offset: u64, info: &BufferCreateInfo<'_>, ) -> Result<Buffer, AllocError>

Recreate one buffer alias on this move’s destination, without allocating memory. Binding/requirements checks and native failure cleanup use the ordinary alias owner. The returned resource is caller-owned and does not replace a recorded primary.

§Safety

Same native creation/alias/barrier contract as mem::create_aliasing_buffer. Recreate every group member at its retained local offset; complete copies, update references and destroy all old aliases before committing the move.

Source

pub unsafe fn create_aliasing_image( &mut self, index: usize, local_offset: u64, info: &ImageCreateInfo<'_>, ) -> Result<Image, AllocError>

Recreate one image alias on the reserved destination, preserving ALIAS_BIT and the ordinary alias owner’s checked requirements/offset/type admission.

§Safety

Same group completion/reference/destruction contract as create_aliasing_buffer, plus mem::create_aliasing_image native image/layout requirements.

Source

pub unsafe fn commit_move( &mut self, index: usize, source: &mut Allocation, ) -> Result<(), AllocError>

Replace the caller’s source token after completed replacement and old-resource destruction.

Keeps copied diagnostic name, opaque user data and pinning metadata. Publishes the already bound destination and frees the old placement; no resource is created/destroyed and no GPU work is submitted or waited on.

§Errors

Rejects wrong/stale source, unresolved primary destination binding, or a mapping/guard/native failure. Raw storage may commit without a recorded binding.

§Safety

Copy/initialization must be complete. Destroy the old source resource first; update all dependent descriptors, addresses, views and consumer references before subsequent use. Caller owns the replacement’s identity/callback lifetime. For aliasable storage retire the entire old alias group. End all uses of old mapped pointers before this call; counted explicit/persistent holds transfer to the destination. Obtain its new pointer from the destination snapshot or mapped_pointer after the context ends. Old pointers never update themselves.

Source

pub unsafe fn ignore_move(&mut self, index: usize) -> Result<(), AllocError>

Release one unused destination, retaining its original source unchanged.

§Safety

Destroy every bound replacement/alias and complete all its uses first. End every destination mapped-pointer use; source mapping holds stay intact.

Source

pub unsafe fn destroy_move( &mut self, index: usize, source: &mut Allocation, ) -> Result<(), AllocError>

Discard a source allocation instead of moving it, releasing both reservations.

§Errors

Rejects stale/wrong source, resolved moves or guard/native release failures.

§Safety

Destroy the old source and any bound replacement resource first and complete all their uses. Caller must discard every dependent descriptor/address/view. Destroy every alias and end all source/destination mapped-pointer uses; counted mapping holds are explicitly retired with their storage.

Source

pub unsafe fn abort(&mut self) -> Result<DefragmentationStats, AllocError>

Release every unresolved destination; completed moves remain committed.

§Safety

Destroy all unresolved replacement resources/aliases and complete their uses first. End every unresolved destination mapped-pointer use before this call.

Source

pub fn finish(&mut self) -> Result<DefragmentationStats, AllocError>

Close the host pass after every proposed move has been committed or ignored.

Auto Trait Implementations§

§

impl<'allocator, 'device> !Send for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> !Sync for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> !UnwindSafe for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> Forget for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> Freeze for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> Move for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> RefUnwindSafe for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> Unpin for DefragmentationPass<'allocator, 'device>

§

impl<'allocator, 'device> UnsafeUnpin for DefragmentationPass<'allocator, 'device>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.