vk::mem · Structs · D1
8 public declarations with native signatures and source-owned contracts.
Stvk::mem::DebugMemorySettings
Contract
Opt-in host-visible debug instrumentation, configured before native acquisition. Guard margins follow VMA’s coherent pooled-memory policy. Zero disables guards.
Fields
margin
margin: u64Trailing guard bytes, a multiple of four. Separate native allocations have no guard tail.
initialize_allocations
initialize_allocations: boolInitialize admitted host-visible allocation bytes with VMA’s created pattern (0xDC).
poison_frees
poison_frees: boolOverwrite admitted host-visible bytes with VMA’s destroyed pattern (0xEF) on release.
Methods and associated items
new
Construct the record with its default state.
set_margin
Set margin and return the updated record.
set_initialize_allocations
Set initialize_allocations and return the updated record.
set_poison_frees
Set poison_frees and return the updated record.
clone
fmt
default
eq
self and other values to be equal, and is used by ==.Stvk::mem::DefragmentationContext
Contract
Persistent multi-pass relocation state with one exclusive allocator borrow.
Ignored allocations stay immovable for subsequent passes in this context.
Each pass must be explicitly resolved and finished; neither context nor pass
Drop submits, waits or destroys native resources. An abandoned unresolved pass
leaks its reservations, as documented by DefragmentationPass.
Initial per-domain order, Balanced averages and Extensive evacuation/packing
phases persist across passes. Extensive holds its blocks for reuse until
explicit finish; Drop clears host holds but never frees native memory.
Methods and associated items
new
Retain one allocator and optional TLSF pool for successive bounded passes.
No placement reservation or native effect occurs until begin_pass.
Errors
Rejects closed/foreign/stale pools, linear-pool relocation and host metadata failure.
begin_pass
Reserve another bounded pass, excluding previously ignored source identities.
Extensive may move into a later evacuated block to pack compatible classes.
is_empty means this pass proposed no move under its policy and copy limits.
Errors
Preserves policy/host metadata/planning errors without changing source storage.
Safety
Same live-source, completed-copy and explicit move-resolution obligations as
mem::begin_defragmentation. Finish/abort every pass before beginning another.
begin_pass_with_break
Plan the next pass with a stop predicate borrowed only for this call.
True preserves already proposed moves for resolution; was_interrupted
distinguishes a stopped empty pass from completed scheduling. A later pass
can use a different predicate; this context retains policy and ignored state.
Safety
Same source/alias/mapped-pointer and explicit resolution contract as begin_pass.
statistics
Totals from explicitly finished passes, never uncommitted proposals.
ignored_allocations
finish
Complete the context after all passes are resolved and finished. Extensive explicitly releases held empty blocks above pool minimums here; freed native block/byte counts are included in the returned total statistics.
drop
Stvk::mem::DefragmentationInfo
Contract
Bounded relocation planning. Zero limits produce an empty pass.
Fields
pool
pool: Option<&'pool Pool>max_bytes
max_bytes: u64max_allocations
max_allocations: usizealgorithm
algorithm: DefragmentationAlgorithmMethods and associated items
new
Construct the record with its default state.
set_pool
Set pool and return the updated record.
set_max_bytes
Set max_bytes and return the updated record.
set_max_allocations
Set max_allocations and return the updated record.
set_algorithm
Set algorithm and return the updated record.
clone
fmt
default
Stvk::mem::DefragmentationMove
Contract
Borrow-free binding snapshots. They do not retain resources or mappings. Mapped pointers describe counted holds owned by the pass’s live regions. Source pointers expire on commit/destroy, destination pointers on ignore/destroy; copied snapshots extend no lifetime.
Fields
source
source: AllocationInfodestination
destination: AllocationInforesource
resource: DefragmentationResourcecan_alias
can_alias: boolThe whole alias group must be recreated, copied and retired together.
resource identifies only the recorded primary resource, if any.
Methods and associated items
set_source
Set source and return the updated record.
set_destination
Set destination and return the updated record.
set_resource
Set resource and return the updated record.
set_can_alias
Set can_alias and return the updated record.
clone
fmt
eq
self and other values to be equal, and is used by ==.Stvk::mem::DefragmentationPass
Contract
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.
Methods and associated items
len
Proposed move count, including moves already explicitly resolved.
is_empty
was_interrupted
The stop predicate returned true. An interrupted empty pass does not mean compaction is complete; a later context pass can resume scheduling.
movement
Borrow a proposal’s stable original snapshots; no native ownership is acquired.
device
Access the same borrowed device for explicit replacement/copy/completion operations.
allocation_callbacks
Retained native callbacks for explicit old/replacement resource destruction.
bind_buffer
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.
bind_image
Bind a caller-created replacement image to the reserved destination.
Safety
Caller supplies matching ordinary image requirements/layout/tiling and valid enabled features.
create_aliasing_buffer
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.
create_aliasing_image
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.
commit_move
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.
ignore_move
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.
destroy_move
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.
abort
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.
finish
Close the host pass after every proposed move has been committed or ignored.
Stvk::mem::DefragmentationStats
Contract
Actual completed work; proposed or ignored moves are not counted as moved bytes.
Fields
moved_allocations
moved_allocations: usizemoved_bytes
moved_bytes: u64freed_blocks
freed_blocks: usizefreed_bytes
freed_bytes: u64ignored_allocations
ignored_allocations: usizedestroyed_allocations
destroyed_allocations: usizeMethods and associated items
new
Construct the record with its default state.
set_moved_allocations
Set moved_allocations and return the updated record.
set_moved_bytes
Set moved_bytes and return the updated record.
set_freed_blocks
Set freed_blocks and return the updated record.
set_freed_bytes
Set freed_bytes and return the updated record.
set_ignored_allocations
Set ignored_allocations and return the updated record.
set_destroyed_allocations
Set destroyed_allocations and return the updated record.
clone
fmt
default
eq
self and other values to be equal, and is used by ==.Stvk::mem::DetailedStatistics
pub struct DetailedStatistics {
pub native_count: usize,
pub native_bytes: u64,
pub allocation_count: usize,
pub allocation_bytes: u64,
pub reserved_bytes: u64,
pub free_range_count: usize,
pub free_bytes: u64,
pub allocation_size_min: Option<u64>,
pub allocation_size_max: Option<u64>,
pub free_range_size_min: Option<u64>,
pub free_range_size_max: Option<u64>,
}Contract
Detailed local byte/count statistics. Empty populations have None extrema.
Fields
native_count
native_count: usizenative_bytes
native_bytes: u64allocation_count
allocation_count: usizeallocation_bytes
allocation_bytes: u64reserved_bytes
reserved_bytes: u64free_range_count
free_range_count: usizefree_bytes
free_bytes: u64allocation_size_min
allocation_size_min: Option<u64>allocation_size_max
allocation_size_max: Option<u64>free_range_size_min
free_range_size_min: Option<u64>free_range_size_max
free_range_size_max: Option<u64>Methods and associated items
new
Construct the record with its default state.
set_native_count
Set native_count and return the updated record.
set_native_bytes
Set native_bytes and return the updated record.
set_allocation_count
Set allocation_count and return the updated record.
set_allocation_bytes
Set allocation_bytes and return the updated record.
set_reserved_bytes
Set reserved_bytes and return the updated record.
set_free_range_count
Set free_range_count and return the updated record.
set_free_bytes
Set free_bytes and return the updated record.
set_allocation_size_min
Set allocation_size_min and return the updated record.
set_allocation_size_max
Set allocation_size_max and return the updated record.
set_free_range_size_min
Set free_range_size_min and return the updated record.
set_free_range_size_max
Set free_range_size_max and return the updated record.
clone
fmt
default
eq
self and other values to be equal, and is used by ==.Stvk::mem::DeviceMemoryCallbacks
Contract
Informative notifications for actual native memory allocation/free effects. Callbacks do not allocate Rust metadata and do not own the native memory.
Fields
allocated
allocated: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>freed
freed: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>p_user_data
p_user_data: *mut c_voidMethods and associated items
new
Construct the record with its default state.
set_allocated
Set allocated and return the updated record.
set_freed
Set freed and return the updated record.
set_p_user_data
Set p_user_data and return the updated record.