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<'_, '_>
impl DefragmentationPass<'_, '_>
pub fn is_empty(&self) -> bool
Sourcepub fn was_interrupted(&self) -> bool
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.
Sourcepub fn movement(&self, index: usize) -> Result<&DefragmentationMove, AllocError>
pub fn movement(&self, index: usize) -> Result<&DefragmentationMove, AllocError>
Borrow a proposal’s stable original snapshots; no native ownership is acquired.
Sourcepub fn device(&self) -> &Device
pub fn device(&self) -> &Device
Access the same borrowed device for explicit replacement/copy/completion operations.
Sourcepub fn allocation_callbacks(&self) -> Option<&AllocationCallbacks>
pub fn allocation_callbacks(&self) -> Option<&AllocationCallbacks>
Retained native callbacks for explicit old/replacement resource destruction.
Sourcepub unsafe fn bind_buffer(
&mut self,
index: usize,
buffer: Buffer,
) -> Result<(), AllocError>
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.
Sourcepub unsafe fn bind_image(
&mut self,
index: usize,
image: Image,
) -> Result<(), AllocError>
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.
Sourcepub unsafe fn create_aliasing_buffer(
&mut self,
index: usize,
local_offset: u64,
info: &BufferCreateInfo<'_>,
) -> Result<Buffer, AllocError>
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.
Sourcepub unsafe fn create_aliasing_image(
&mut self,
index: usize,
local_offset: u64,
info: &ImageCreateInfo<'_>,
) -> Result<Image, AllocError>
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.
Sourcepub unsafe fn commit_move(
&mut self,
index: usize,
source: &mut Allocation,
) -> Result<(), AllocError>
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.
Sourcepub unsafe fn ignore_move(&mut self, index: usize) -> Result<(), AllocError>
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.
Sourcepub unsafe fn destroy_move(
&mut self,
index: usize,
source: &mut Allocation,
) -> Result<(), AllocError>
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.
Sourcepub unsafe fn abort(&mut self) -> Result<DefragmentationStats, AllocError>
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.
Sourcepub fn finish(&mut self) -> Result<DefragmentationStats, AllocError>
pub fn finish(&mut self) -> Result<DefragmentationStats, AllocError>
Close the host pass after every proposed move has been committed or ignored.