vk::mem · Structs · A1
7 public declarations with native signatures and source-owned contracts.
Stvk::mem::Allocation
Contract
One live native region. No implicit free, unmap, submission or wait in Drop.
Methods and associated items
handle
offset
size
reserved_size
Native extent reserved to this region, including non-coherent atom padding.
memory_type_index
heap_index
is_host_coherent
is_host_visible
is_freed
mapped_range
Translate an allocation-relative range to a native block range. This does not validate allocator liveness or establish a mapping.
Donor: VMA VmaAllocator_T::GetFlushOrInvalidateRange.
Adaptation: checked arithmetic, no-op ranges, allocation-end exception.
Stvk::mem::AllocationChain
Contract
A caller-owned VkMemoryAllocateInfo::pNext chain.
The allocator prepends its dedication and admitted priority/address records. Explicit flags are preserved, including a device mask; resource dedication and priority belong to the allocator and must not also appear in this chain. No native handle is owned by this borrowed descriptor.
Methods and associated items
new_from_record
Borrow a registered allocation extension and its linked records.
Errors
Rejects cycles, duplicate tags, overlong chains, allocator-owned records and native records without an admitted allocator ownership/accounting contract.
Safety
Every reachable header and full payload must be valid, correctly tagged,
immutable and readable for 'a; all nested pointers/handles and enabled
capabilities must meet native valid usage at allocation. Imports must use
an explicitly compatible memory type/size. Native import handle transfer
occurs on successful vkAllocateMemory, even if later mapping/binding fails.
new_from_record_with_import
Borrow an import chain with explicit external payload accounting.
Use this for platform imports whose native allocation size is ignored or whose compatible types come from external properties. No OS query is guessed.
Errors
Same chain validation as new_from_record, plus absent/invalid import
metadata, null resource identities and incompatible dedication policy.
Safety
The complete new_from_record contract applies. info must describe this
exact payload and device: obtain size/types from the platform Vulkan query
or authoritative OS/export metadata. Include all backing bytes, even when
native allocationSize is ignored/zero. A supplied resource must be live,
unbound, compatible, and have requirements covered by this size/type mask.
Every native dedication rule still applies, including an exact requirements
size wherever required. Fuchsia collection resource/index/size must match.
Android/QNX/OHOS image profiles and Metal textures require their image.
External host/OS objects must survive every native use, not just this borrow.
as_ptr
clone
fmt
Stvk::mem::AllocationCreateInfo
pub struct AllocationCreateInfo<'pool> {
pub within_budget: bool,
pub dedicated_memory: bool,
pub memory_allocate_next: Option<AllocationChain<'pool>>,
pub never_allocate: bool,
pub can_alias: bool,
pub priority: MemoryPriority,
pub min_allocation_alignment: u64,
pub pool: Option<&'pool Pool>,
pub usage: MemoryUsage,
pub host_access: HostAccess,
pub allow_transfer_instead: bool,
pub avoided_flags: MemoryPropertyFlags,
pub required_flags: MemoryPropertyFlags,
pub preferred_flags: MemoryPropertyFlags,
pub memory_type_bits: u32,
pub strategy: PlacementStrategy,
pub upper_address: bool,
pub policy: AllocationPolicy,
pub persistent_map: bool,
}Contract
Managed-resource policy, including optional borrowed native allocation storage; this Rust record is not part of the Vulkan ABI.
Fields
within_budget
within_budget: boolGate new native memory against owned cached/refreshed budgets; reuse needs no new budget.
dedicated_memory
dedicated_memory: boolForce separate native storage, including in automatic custom pools.
memory_allocate_next
memory_allocate_next: Option<AllocationChain<'pool>>Borrowed native allocation chain. Implies separate storage; never combined with a pool chain. Imports are attempted once and never initialized/poisoned.
never_allocate
never_allocate: boolReuse existing pool storage only; never grow or fall back to separate native storage.
can_alias
can_alias: boolReserve conservatively for alias resources and omit resource-specific dedication.
priority
priority: MemoryPriorityNon-default priority requires captured enabled EXT_memory_priority.
min_allocation_alignment
min_allocation_alignment: u64Additional offset alignment; zero means only native/pool/atom constraints. Otherwise a power of two, combined with every mandatory alignment.
pool
pool: Option<&'pool Pool>Fixed-type custom pool. Overrides policy; native type compatibility and
required properties remain mandatory. No fallback outside this pool.
Pool policy storage cannot outlive or be used after destroying its pool:
ⓘlet options = vk::mem::AllocationCreateInfo::new().set_pool(Some(pool));
allocator.destroy_pool(pool).unwrap();
assert!(!options.pool.unwrap().is_destroyed());usage
usage: MemoryUsagehost_access
host_access: HostAccessAutomatic host intent also prefers already mapped compatible blocks. Explicit usage retains mapping intent; absence of automatic intent prefers unmapped blocks.
allow_transfer_instead
allow_transfer_instead: boolPermit automatic selection of non-host-visible memory; caller supplies staging.
avoided_flags
avoided_flags: MemoryPropertyFlagsProperties penalized during memory-type selection; never a hard exclusion.
required_flags
required_flags: MemoryPropertyFlagspreferred_flags
preferred_flags: MemoryPropertyFlagsmemory_type_bits
memory_type_bits: u32Intersected with queried native requirements; zero admits no memory types.
strategy
strategy: PlacementStrategyTLSF block search is forward except MinTime, which searches in reverse. Other strategies group host-visible blocks by mapping preference first.
upper_address
upper_address: boolAllocate downward in a single-block linear custom pool. Other routes reject it.
policy
policy: AllocationPolicypersistent_map
persistent_map: boolRetain a mapping until explicit allocation release. Requires host-visible storage.
Methods and associated items
new
Construct the record with its default state.
set_within_budget
Set within_budget and return the updated record.
set_dedicated_memory
Set dedicated_memory and return the updated record.
set_memory_allocate_next
Set memory_allocate_next and return the updated record.
The descriptor retains its chain storage borrow:
ⓘlet options;
{
let record = vk::ExportMemoryAllocateInfo::new();
// SAFETY: this correctly tagged record has no linked or nested storage.
let chain = unsafe { vk::mem::AllocationChain::new_from_record(&record) }.unwrap();
options = vk::mem::AllocationCreateInfo::new()
.set_memory_allocate_next(Some(chain))
.set_dedicated_memory(true);
}
assert!(options.memory_allocate_next.is_some());set_never_allocate
Set never_allocate and return the updated record.
set_can_alias
Set can_alias and return the updated record.
set_priority
Set priority and return the updated record.
set_min_allocation_alignment
Set min_allocation_alignment and return the updated record.
set_pool
Set pool and return the updated record.
set_usage
Set usage and return the updated record.
set_host_access
Set host_access and return the updated record.
set_allow_transfer_instead
Set allow_transfer_instead and return the updated record.
set_avoided_flags
Set avoided_flags and return the updated record.
set_required_flags
Set required_flags and return the updated record.
set_preferred_flags
Set preferred_flags and return the updated record.
set_memory_type_bits
Set memory_type_bits and return the updated record.
set_strategy
Set strategy and return the updated record.
set_upper_address
Set upper_address and return the updated record.
set_policy
Set policy and return the updated record.
set_persistent_map
Set persistent_map and return the updated record.
clone
fmt
default
Stvk::mem::AllocationInfo
pub struct AllocationInfo {
pub device_memory: DeviceMemory,
pub offset: u64,
pub size: u64,
pub reserved_size: u64,
pub memory_type_index: u32,
pub heap_index: u32,
pub memory_properties: MemoryPropertyFlags,
pub mapped_pointer: Option<*mut c_void>,
pub map_count: u32,
pub native_size: u64,
pub is_separate: bool,
pub user_data: usize,
}Contract
Checked binding and mapping snapshot of one live allocation.
Offsets and sizes are native bytes. size is the queried memory requirement,
not necessarily the logical buffer size or a linear image’s pixel extent.
Copying a snapshot does not retain its allocation, mapping or native objects.
Query again after mapping changes; never use a saved pointer after unmap/free.
Fields
device_memory
device_memory: DeviceMemoryoffset
offset: u64size
size: u64reserved_size
reserved_size: u64Includes non-coherent atom padding reserved to a pooled region.
memory_type_index
memory_type_index: u32heap_index
heap_index: u32memory_properties
memory_properties: MemoryPropertyFlagsActual selected memory properties, rather than requested preferences.
mapped_pointer
mapped_pointer: Option<*mut c_void>Allocation-relative pointer, present only for this region’s mapping hold. Observing this pointer does not acquire a hold or authorize dereferencing it.
map_count
map_count: u32Explicit mapping holds; persistent mapping is independent.
native_size
native_size: u64Size of the backing native memory object, including other pooled regions.
is_separate
is_separate: boolSeparate native storage rather than a pooled placement (not proof of native dedication).
user_data
user_data: usizeOpaque consumer metadata. No dereference or ownership is inferred.
Methods and associated items
set_device_memory
Set device_memory and return the updated record.
set_offset
Set offset and return the updated record.
set_size
Set size and return the updated record.
set_reserved_size
Set reserved_size and return the updated record.
set_memory_type_index
Set memory_type_index and return the updated record.
set_heap_index
Set heap_index and return the updated record.
set_memory_properties
Set memory_properties and return the updated record.
set_mapped_pointer
Set mapped_pointer and return the updated record.
set_map_count
Set map_count and return the updated record.
set_native_size
Set native_size and return the updated record.
set_is_separate
Set is_separate and return the updated record.
set_user_data
Set user_data and return the updated record.
clone
fmt
eq
self and other values to be equal, and is used by ==.Stvk::mem::AllocatorInfo
Contract
Captured native identities. Manual metadata constructors do not invent parent identities.
Fields
device
device: DeviceHandleinstance
instance: Option<InstanceHandle>physical_device
physical_device: Option<PhysicalDevice>api_version
api_version: Option<u32>Methods and associated items
set_device
Set device and return the updated record.
set_instance
Set instance and return the updated record.
set_physical_device
Set physical_device and return the updated record.
set_api_version
Set api_version and return the updated record.
clone
fmt
eq
self and other values to be equal, and is used by ==.Stvk::mem::AllocatorStats
Contract
Local accounting snapshot; excludes allocations made by other allocators/raw calls.
Fields
allocation_count
allocation_count: usizenative_allocation_count
native_allocation_count: usizepooled_block_count
pooled_block_count: usizeallocation_bytes
allocation_bytes: u64Sum of native requirements sizes, or full accounted external import extents.
reserved_bytes
reserved_bytes: u64Includes cache-atom padding reserved to live pooled regions.
native_bytes
native_bytes: u64mapped_native_count
mapped_native_count: usizeMethods and associated items
new
Construct the record with its default state.
set_allocation_count
Set allocation_count and return the updated record.
set_native_allocation_count
Set native_allocation_count and return the updated record.
set_pooled_block_count
Set pooled_block_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_native_bytes
Set native_bytes and return the updated record.
set_mapped_native_count
Set mapped_native_count and return the updated record.
clone
fmt
default
eq
self and other values to be equal, and is used by ==.Stvk::mem::AllocRequest
Fields
size
size: u64alignment
alignment: u64memory_type_bits
memory_type_bits: u32required_flags
required_flags: MemoryPropertyFlagspreferred_flags
preferred_flags: MemoryPropertyFlagsMethods and associated items
new
Construct explicit requirements with no required or preferred properties. The selector/allocation operation validates size, alignment and type compatibility.
set_size
Set size and return the updated record.
set_alignment
Set alignment and return the updated record.
set_memory_type_bits
Set memory_type_bits and return the updated record.
set_required_flags
Set required_flags and return the updated record.
set_preferred_flags
Set preferred_flags and return the updated record.