Realm

vk::mem · Structs · A1

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

StRustExperimental

Stvk::mem::Allocation

Contract

One live native region. No implicit free, unmap, submission or wait in Drop.

Methods and associated items

handle

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

offset

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

size

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

reserved_size

Method
pub fn reserved_size(&self) -> u64

Native extent reserved to this region, including non-coherent atom padding.

memory_type_index

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

heap_index

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

is_host_coherent

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

is_host_visible

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

is_freed

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

mapped_range

Method
pub fn mapped_range( &self, offset: u64, size: u64, ) -> Result<Option<MappedMemoryRange<'static>>, AllocError>

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

Method
pub unsafe fn new_from_record<T: Extends<MemoryAllocateInfo<'a>>>( record: &'a T, ) -> Result<Self, AllocError>

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

Method
pub unsafe fn new_from_record_with_import<T: Extends<MemoryAllocateInfo<'a>>>( record: &'a T, info: ImportMemoryInfo, ) -> Result<Self, AllocError>

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

Method
pub fn as_ptr(&self) -> *const c_void
No public source comment is attached to this declaration.

fmt

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

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, }
Managed-resource policy, including optional borrowed native allocation storage; this Rust record is not part of the Vulkan ABI.

Contract

Managed-resource policy, including optional borrowed native allocation storage; this Rust record is not part of the Vulkan ABI.

Fields

within_budget

Field
within_budget: bool

Gate new native memory against owned cached/refreshed budgets; reuse needs no new budget.

dedicated_memory

Field
dedicated_memory: bool

Force separate native storage, including in automatic custom pools.

memory_allocate_next

Field
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

Field
never_allocate: bool

Reuse existing pool storage only; never grow or fall back to separate native storage.

can_alias

Field
can_alias: bool

Reserve conservatively for alias resources and omit resource-specific dedication.

priority

Field
priority: MemoryPriority

Non-default priority requires captured enabled EXT_memory_priority.

min_allocation_alignment

Field
min_allocation_alignment: u64

Additional offset alignment; zero means only native/pool/atom constraints. Otherwise a power of two, combined with every mandatory alignment.

pool

Field
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

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

host_access

Field
host_access: HostAccess

Automatic host intent also prefers already mapped compatible blocks. Explicit usage retains mapping intent; absence of automatic intent prefers unmapped blocks.

allow_transfer_instead

Field
allow_transfer_instead: bool

Permit automatic selection of non-host-visible memory; caller supplies staging.

avoided_flags

Field
avoided_flags: MemoryPropertyFlags

Properties penalized during memory-type selection; never a hard exclusion.

required_flags

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

preferred_flags

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

memory_type_bits

Field
memory_type_bits: u32

Intersected with queried native requirements; zero admits no memory types.

strategy

Field
strategy: PlacementStrategy

TLSF block search is forward except MinTime, which searches in reverse. Other strategies group host-visible blocks by mapping preference first.

upper_address

Field
upper_address: bool

Allocate downward in a single-block linear custom pool. Other routes reject it.

policy

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

persistent_map

Field
persistent_map: bool

Retain a mapping until explicit allocation release. Requires host-visible storage.

Methods and associated items

new

Method
pub fn new() -> Self

Construct the record with its default state.

set_within_budget

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

Set within_budget and return the updated record.

set_dedicated_memory

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

Set dedicated_memory and return the updated record.

set_memory_allocate_next

Method
pub fn set_memory_allocate_next( self, value: Option<AllocationChain<'pool>>, ) -> Self

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

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

Set never_allocate 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.

set_priority

Method
pub fn set_priority(self, value: MemoryPriority) -> Self

Set priority and return the updated record.

set_pool

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

Set pool and return the updated record.

set_usage

Method
pub fn set_usage(self, value: MemoryUsage) -> Self

Set usage and return the updated record.

set_host_access

Method
pub fn set_host_access(self, value: HostAccess) -> Self

Set host_access and return the updated record.

set_avoided_flags

Method
pub fn set_avoided_flags(self, value: MemoryPropertyFlags) -> Self

Set avoided_flags and return the updated record.

set_required_flags

Method
pub fn set_required_flags(self, value: MemoryPropertyFlags) -> Self

Set required_flags and return the updated record.

set_preferred_flags

Method
pub fn set_preferred_flags(self, value: MemoryPropertyFlags) -> Self

Set preferred_flags and return the updated record.

set_memory_type_bits

Method
pub fn set_memory_type_bits(self, value: u32) -> Self

Set memory_type_bits and return the updated record.

set_strategy

Method
pub fn set_strategy(self, value: PlacementStrategy) -> Self

Set strategy and return the updated record.

set_upper_address

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

Set upper_address and return the updated record.

set_policy

Method
pub fn set_policy(self, value: AllocationPolicy) -> Self

Set policy and return the updated record.

set_persistent_map

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

Set persistent_map and return the updated record.

clone

Method
fn clone(&self) -> AllocationCreateInfo<'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::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, }
Checked binding and mapping snapshot of one live allocation.

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

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

offset

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

size

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

reserved_size

Field
reserved_size: u64

Includes non-coherent atom padding reserved to a pooled region.

memory_type_index

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

heap_index

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

memory_properties

Field
memory_properties: MemoryPropertyFlags

Actual selected memory properties, rather than requested preferences.

mapped_pointer

Field
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

Field
map_count: u32

Explicit mapping holds; persistent mapping is independent.

native_size

Field
native_size: u64

Size of the backing native memory object, including other pooled regions.

is_separate

Field
is_separate: bool

Separate native storage rather than a pooled placement (not proof of native dedication).

user_data

Field
user_data: usize

Opaque consumer metadata. No dereference or ownership is inferred.

Methods and associated items

set_device_memory

Method
pub fn set_device_memory(self, value: DeviceMemory) -> Self

Set device_memory and return the updated record.

set_offset

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

Set offset and return the updated record.

set_size

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

Set size and return the updated record.

set_reserved_size

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

Set reserved_size and return the updated record.

set_memory_type_index

Method
pub fn set_memory_type_index(self, value: u32) -> Self

Set memory_type_index and return the updated record.

set_heap_index

Method
pub fn set_heap_index(self, value: u32) -> Self

Set heap_index and return the updated record.

set_memory_properties

Method
pub fn set_memory_properties(self, value: MemoryPropertyFlags) -> Self

Set memory_properties and return the updated record.

set_mapped_pointer

Method
pub fn set_mapped_pointer(self, value: Option<*mut c_void>) -> Self

Set mapped_pointer and return the updated record.

set_map_count

Method
pub fn set_map_count(self, value: u32) -> Self

Set map_count and return the updated record.

set_native_size

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

Set native_size and return the updated record.

set_is_separate

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

Set is_separate and return the updated record.

set_user_data

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

Set user_data 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: &AllocationInfo) -> bool
Tests for self and other values to be equal, and is used by ==.

Stvk::mem::AllocatorInfo

pub struct AllocatorInfo { pub device: DeviceHandle, pub instance: Option<InstanceHandle>, pub physical_device: Option<PhysicalDevice>, pub api_version: Option<u32>, }
Captured native identities. Manual metadata constructors do not invent parent identities.

Contract

Captured native identities. Manual metadata constructors do not invent parent identities.

Fields

device

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

instance

Field
instance: Option<InstanceHandle>
No public source comment is attached to this declaration.

physical_device

Field
physical_device: Option<PhysicalDevice>
No public source comment is attached to this declaration.

api_version

Field
api_version: Option<u32>
No public source comment is attached to this declaration.

Methods and associated items

set_device

Method
pub fn set_device(self, value: DeviceHandle) -> Self

Set device and return the updated record.

set_instance

Method
pub fn set_instance(self, value: Option<InstanceHandle>) -> Self

Set instance and return the updated record.

set_physical_device

Method
pub fn set_physical_device(self, value: Option<PhysicalDevice>) -> Self

Set physical_device and return the updated record.

set_api_version

Method
pub fn set_api_version(self, value: Option<u32>) -> Self

Set api_version 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: &AllocatorInfo) -> bool
Tests for self and other values to be equal, and is used by ==.

Stvk::mem::AllocatorStats

pub struct AllocatorStats { pub allocation_count: usize, pub native_allocation_count: usize, pub pooled_block_count: usize, pub allocation_bytes: u64, pub reserved_bytes: u64, pub native_bytes: u64, pub mapped_native_count: usize, }
Local accounting snapshot; excludes allocations made by other allocators/raw calls.

Contract

Local accounting snapshot; excludes allocations made by other allocators/raw calls.

Fields

allocation_count

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

native_allocation_count

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

pooled_block_count

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

allocation_bytes

Field
allocation_bytes: u64

Sum of native requirements sizes, or full accounted external import extents.

reserved_bytes

Field
reserved_bytes: u64

Includes cache-atom padding reserved to live pooled regions.

native_bytes

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

mapped_native_count

Field
mapped_native_count: 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_allocation_count

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

Set allocation_count and return the updated record.

set_pooled_block_count

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

Set pooled_block_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_native_bytes

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

Set native_bytes 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() -> AllocatorStats
Returns the “default value” for a type. Read more

eq

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

Stvk::mem::AllocRequest

pub struct AllocRequest { pub size: u64, pub alignment: u64, pub memory_type_bits: u32, pub required_flags: MemoryPropertyFlags, pub preferred_flags: MemoryPropertyFlags, }
No public source comment is attached to this declaration.

Fields

size

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

alignment

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

memory_type_bits

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

required_flags

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

preferred_flags

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

Methods and associated items

new

Method
pub fn new(size: u64, alignment: u64, memory_type_bits: u32) -> Self

Construct explicit requirements with no required or preferred properties. The selector/allocation operation validates size, alignment and type compatibility.

set_size

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

Set size and return the updated record.

set_alignment

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

Set alignment and return the updated record.

set_memory_type_bits

Method
pub fn set_memory_type_bits(self, value: u32) -> Self

Set memory_type_bits and return the updated record.

set_required_flags

Method
pub fn set_required_flags(self, value: MemoryPropertyFlags) -> Self

Set required_flags and return the updated record.

set_preferred_flags

Method
pub fn set_preferred_flags(self, value: MemoryPropertyFlags) -> Self

Set preferred_flags and return the updated record.