Realm

vk::mem · Structs · D1

8 public declarations with native signatures and source-owned contracts.

StRustExperimental

Stvk::mem::DebugMemorySettings

pub struct DebugMemorySettings { pub margin: u64, pub initialize_allocations: bool, pub poison_frees: bool, }
Opt-in host-visible debug instrumentation, configured before native acquisition. Guard margins follow VMA’s coherent pooled-memory policy. Zero disables guards.

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

Field
margin: u64

Trailing guard bytes, a multiple of four. Separate native allocations have no guard tail.

initialize_allocations

Field
initialize_allocations: bool

Initialize admitted host-visible allocation bytes with VMA’s created pattern (0xDC).

poison_frees

Field
poison_frees: bool

Overwrite admitted host-visible bytes with VMA’s destroyed pattern (0xEF) on release.

Methods and associated items

new

Method
pub fn new() -> Self

Construct the record with its default state.

set_margin

Method
pub fn set_margin(self, value: u64) -> Self

Set margin and return the updated record.

set_poison_frees

Method
pub fn set_poison_frees(self, value: bool) -> Self

Set poison_frees and return the updated record.

fmt

Method
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more

default

Method
fn default() -> DebugMemorySettings
Returns the “default value” for a type. Read more

eq

Method
fn eq(&self, other: &DebugMemorySettings) -> bool
Tests for self and other values to be equal, and is used by ==.

Stvk::mem::DefragmentationContext

pub struct DefragmentationContext<'allocator, 'device> { /* private fields */ }
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.

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

Method
pub fn new( allocator: &'allocator mut Allocator<'device>, info: &DefragmentationInfo<'_>, ) -> Result<Self, AllocError>

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

Method
pub unsafe fn begin_pass( &mut self, ) -> Result<DefragmentationPass<'_, 'device>, AllocError>

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

Method
pub unsafe fn begin_pass_with_break( &mut self, should_break: &mut dyn FnMut() -> bool, ) -> Result<DefragmentationPass<'_, 'device>, AllocError>

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

Method
pub fn statistics(&self) -> DefragmentationStats

Totals from explicitly finished passes, never uncommitted proposals.

ignored_allocations

Method
pub fn ignored_allocations(&self) -> usize
No public source comment is attached to this declaration.

finish

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

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.

Stvk::mem::DefragmentationInfo

pub struct DefragmentationInfo<'pool> { pub pool: Option<&'pool Pool>, pub max_bytes: u64, pub max_allocations: usize, pub algorithm: DefragmentationAlgorithm, }
Bounded relocation planning. Zero limits produce an empty pass.

Contract

Bounded relocation planning. Zero limits produce an empty pass.

Fields

pool

Field
pool: Option<&'pool Pool>
No public source comment is attached to this declaration.

max_bytes

Field
max_bytes: u64
No public source comment is attached to this declaration.

max_allocations

Field
max_allocations: usize
No public source comment is attached to this declaration.

algorithm

Field
algorithm: DefragmentationAlgorithm
No public source comment is attached to this declaration.

Methods and associated items

new

Method
pub fn new() -> Self

Construct the record with its default state.

set_pool

Method
pub fn set_pool(self, value: Option<&'pool Pool>) -> Self

Set pool and return the updated record.

set_max_bytes

Method
pub fn set_max_bytes(self, value: u64) -> Self

Set max_bytes and return the updated record.

set_max_allocations

Method
pub fn set_max_allocations(self, value: usize) -> Self

Set max_allocations and return the updated record.

set_algorithm

Method
pub fn set_algorithm(self, value: DefragmentationAlgorithm) -> Self

Set algorithm and return the updated record.

clone

Method
fn clone(&self) -> DefragmentationInfo<'pool>
Returns a duplicate of the value. Read more

fmt

Method
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more

Stvk::mem::DefragmentationMove

pub struct DefragmentationMove { pub source: AllocationInfo, pub destination: AllocationInfo, pub resource: DefragmentationResource, pub can_alias: bool, }
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.

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

Field
source: AllocationInfo
No public source comment is attached to this declaration.

destination

Field
destination: AllocationInfo
No public source comment is attached to this declaration.

resource

Field
resource: DefragmentationResource
No public source comment is attached to this declaration.

can_alias

Field
can_alias: bool

The 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

Method
pub fn set_source(self, value: AllocationInfo) -> Self

Set source and return the updated record.

set_destination

Method
pub fn set_destination(self, value: AllocationInfo) -> Self

Set destination and return the updated record.

set_resource

Method
pub fn set_resource(self, value: DefragmentationResource) -> Self

Set resource and return the updated record.

set_can_alias

Method
pub fn set_can_alias(self, value: bool) -> Self

Set can_alias and return the updated record.

fmt

Method
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more

eq

Method
fn eq(&self, other: &DefragmentationMove) -> bool
Tests for 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

Method
pub fn len(&self) -> usize

Proposed move count, including moves already explicitly resolved.

is_empty

Method
pub fn is_empty(&self) -> bool
No public source comment is attached to this declaration.

was_interrupted

Method
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.

movement

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

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

device

Method
pub fn device(&self) -> &Device

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

allocation_callbacks

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

Retained native callbacks for explicit old/replacement resource destruction.

bind_buffer

Method
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.

bind_image

Method
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.

create_aliasing_buffer

Method
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.

create_aliasing_image

Method
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.

commit_move

Method
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.

ignore_move

Method
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.

destroy_move

Method
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.

abort

Method
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.

finish

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

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

Stvk::mem::DefragmentationStats

pub struct DefragmentationStats { pub moved_allocations: usize, pub moved_bytes: u64, pub freed_blocks: usize, pub freed_bytes: u64, pub ignored_allocations: usize, pub destroyed_allocations: usize, }
Actual completed work; proposed or ignored moves are not counted as moved bytes.

Contract

Actual completed work; proposed or ignored moves are not counted as moved bytes.

Fields

moved_allocations

Field
moved_allocations: usize
No public source comment is attached to this declaration.

moved_bytes

Field
moved_bytes: u64
No public source comment is attached to this declaration.

freed_blocks

Field
freed_blocks: usize
No public source comment is attached to this declaration.

freed_bytes

Field
freed_bytes: u64
No public source comment is attached to this declaration.

ignored_allocations

Field
ignored_allocations: usize
No public source comment is attached to this declaration.

destroyed_allocations

Field
destroyed_allocations: usize
No public source comment is attached to this declaration.

Methods and associated items

new

Method
pub fn new() -> Self

Construct the record with its default state.

set_moved_allocations

Method
pub fn set_moved_allocations(self, value: usize) -> Self

Set moved_allocations and return the updated record.

set_moved_bytes

Method
pub fn set_moved_bytes(self, value: u64) -> Self

Set moved_bytes and return the updated record.

set_freed_blocks

Method
pub fn set_freed_blocks(self, value: usize) -> Self

Set freed_blocks and return the updated record.

set_freed_bytes

Method
pub fn set_freed_bytes(self, value: u64) -> Self

Set freed_bytes and return the updated record.

clone

Method
fn clone(&self) -> DefragmentationStats
Returns a duplicate of the value. Read more

fmt

Method
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more

default

Method
fn default() -> DefragmentationStats
Returns the “default value” for a type. Read more

eq

Method
fn eq(&self, other: &DefragmentationStats) -> bool
Tests for 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>, }
Detailed local byte/count statistics. Empty populations have None extrema.

Contract

Detailed local byte/count statistics. Empty populations have None extrema.

Fields

native_count

Field
native_count: usize
No public source comment is attached to this declaration.

native_bytes

Field
native_bytes: u64
No public source comment is attached to this declaration.

allocation_count

Field
allocation_count: usize
No public source comment is attached to this declaration.

allocation_bytes

Field
allocation_bytes: u64
No public source comment is attached to this declaration.

reserved_bytes

Field
reserved_bytes: u64
No public source comment is attached to this declaration.

free_range_count

Field
free_range_count: usize
No public source comment is attached to this declaration.

free_bytes

Field
free_bytes: u64
No public source comment is attached to this declaration.

allocation_size_min

Field
allocation_size_min: Option<u64>
No public source comment is attached to this declaration.

allocation_size_max

Field
allocation_size_max: Option<u64>
No public source comment is attached to this declaration.

free_range_size_min

Field
free_range_size_min: Option<u64>
No public source comment is attached to this declaration.

free_range_size_max

Field
free_range_size_max: Option<u64>
No public source comment is attached to this declaration.

Methods and associated items

new

Method
pub fn new() -> Self

Construct the record with its default state.

set_native_count

Method
pub fn set_native_count(self, value: usize) -> Self

Set native_count and return the updated record.

set_native_bytes

Method
pub fn set_native_bytes(self, value: u64) -> Self

Set native_bytes and return the updated record.

set_allocation_count

Method
pub fn set_allocation_count(self, value: usize) -> Self

Set allocation_count and return the updated record.

set_allocation_bytes

Method
pub fn set_allocation_bytes(self, value: u64) -> Self

Set allocation_bytes and return the updated record.

set_reserved_bytes

Method
pub fn set_reserved_bytes(self, value: u64) -> Self

Set reserved_bytes and return the updated record.

set_free_range_count

Method
pub fn set_free_range_count(self, value: usize) -> Self

Set free_range_count and return the updated record.

set_free_bytes

Method
pub fn set_free_bytes(self, value: u64) -> Self

Set free_bytes and return the updated record.

set_allocation_size_min

Method
pub fn set_allocation_size_min(self, value: Option<u64>) -> Self

Set allocation_size_min and return the updated record.

set_allocation_size_max

Method
pub fn set_allocation_size_max(self, value: Option<u64>) -> Self

Set allocation_size_max and return the updated record.

set_free_range_size_min

Method
pub fn set_free_range_size_min(self, value: Option<u64>) -> Self

Set free_range_size_min and return the updated record.

set_free_range_size_max

Method
pub fn set_free_range_size_max(self, value: Option<u64>) -> Self

Set free_range_size_max and return the updated record.

fmt

Method
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more

default

Method
fn default() -> DetailedStatistics
Returns the “default value” for a type. Read more

eq

Method
fn eq(&self, other: &DetailedStatistics) -> bool
Tests for self and other values to be equal, and is used by ==.

Stvk::mem::DeviceMemoryCallbacks

pub struct DeviceMemoryCallbacks { pub allocated: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>, pub freed: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>, pub p_user_data: *mut c_void, }
Informative notifications for actual native memory allocation/free effects. Callbacks do not allocate Rust metadata and do not own the native memory.

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

Field
allocated: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>
No public source comment is attached to this declaration.

freed

Field
freed: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>
No public source comment is attached to this declaration.

p_user_data

Field
p_user_data: *mut c_void
No public source comment is attached to this declaration.

Methods and associated items

new

Method
pub fn new() -> Self

Construct the record with its default state.

set_allocated

Method
pub fn set_allocated( self, value: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>, ) -> Self

Set allocated and return the updated record.

set_freed

Method
pub fn set_freed( self, value: Option<unsafe extern "system" fn(DeviceHandle, DeviceMemory, u64, u32, *mut c_void)>, ) -> Self

Set freed and return the updated record.

set_p_user_data

Method
pub fn set_p_user_data(self, value: *mut c_void) -> Self

Set p_user_data and return the updated record.

clone

Method
fn clone(&self) -> DeviceMemoryCallbacks
Returns a duplicate of the value. Read more

default

Method
fn default() -> DeviceMemoryCallbacks
Returns the “default value” for a type. Read more