Realm

vk::mem · Functions · A1

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

FnRustExperimental

Fnvk::mem::allocate

pub unsafe fn allocate( allocator: &mut Allocator<'_>, request: &AllocRequest, ) -> Result<Allocation, AllocError>
Allocate separate native storage with automatically admitted allocation flags.

Contract

Allocate separate native storage with automatically admitted allocation flags.

Safety

Requirements, size/count limits and enabled features must be valid. Required dedication and per-request import chains are excluded. Configured exports apply to the selected type. Protected memory requires captured enabled feature metadata. When owned device metadata enables core/KHR buffer device address, raw storage carries its flag.

Fnvk::mem::allocate_dedicated

pub unsafe fn allocate_dedicated<'a>( allocator: &mut Allocator<'_>, requirements: &MemoryRequirements, options: &AllocationCreateInfo<'a>, chain: Option<AllocationChain<'a>>, ) -> Result<Allocation, AllocError>
Allocate separate native storage with an optional borrowed allocation chain. Equivalent to allocate_with_options with dedicated_memory enabled.

Contract

Allocate separate native storage with an optional borrowed allocation chain. Equivalent to allocate_with_options with dedicated_memory enabled.

Errors

Preserves ordinary policy/type/native failures and rejects conflicting chains.

Safety

Requirements/type/size and every chain payload must meet native valid usage. Successful native imports transfer handles according to their Vulkan contract, even if later setup fails; imported contents are not debug-filled or poisoned.

Fnvk::mem::allocate_for_buffer

pub unsafe fn allocate_for_buffer( allocator: &mut Allocator<'_>, buffer: Buffer, options: &AllocationCreateInfo<'_>, ) -> Result<Allocation, AllocError>
Allocate for a caller-created unbound ordinary buffer without creating, binding or destroying it.

Contract

Allocate for a caller-created unbound ordinary buffer without creating, binding or destroying it.

Queries exact legacy/core/KHR requirements and dedication. Imports carrying resource-specific ImportMemoryInfo instead use those admitted external requirements without an otherwise illegal pre-bind native query. Policy must use MemoryUsage::Explicit; creation usage is unavailable from the opaque handle. BDA-enabled allocators flag separate buffer storage conservatively, following VMA. Allocation/map failure retains the caller’s resource. Release unbound storage with free; bind it explicitly with bind_buffer_memory when ready.

Errors

Rejects null/already-associated resources, unsupported policy, identity/type/ limit failures or preserves the native allocation/map/query error.

Safety

Buffer must be live, unbound, from this device and remain so until binding or allocation release. Supply ordinary non-sparse, non-capture/replay resource semantics; admitted import chains retain their exact external metadata/handle obligations. Address usage requires enabled core/KHR BDA metadata. Protected storage requires enabled features and explicit flags. The caller owns resource lifetime, callbacks and synchronization.

Fnvk::mem::allocate_for_image

pub unsafe fn allocate_for_image( allocator: &mut Allocator<'_>, image: Image, options: &AllocationCreateInfo<'_>, ) -> Result<Allocation, AllocError>
Allocate for a caller-created unbound ordinary image; no creation, binding or destruction.

Contract

Allocate for a caller-created unbound ordinary image; no creation, binding or destruction.

Unknown tiling conflicts with every native class, including another unknown image, on a granularity page. Explicit memory flags are required. Native requirements/dedication, pool limits, persistent mapping and rollback share the managed-resource implementation. Resource-specific import metadata replaces pre-bind queries where native external-memory rules forbid them. Failure retains the caller’s handle.

Errors

Same checked policy, identity/type/limit and native errors as allocate_for_buffer.

Safety

Image must be live, unbound and from this device. Sparse, disjoint, DRM-modifier, implicit aliasing and unsupported allocation capabilities are excluded. Ordinary external allocation profiles retain caller-owned native compatibility obligations. Protected storage requires captured enablement and explicit required flags. The caller owns resource lifetime, callbacks, valid usage and synchronization.

Fnvk::mem::allocate_many

pub unsafe fn allocate_many( allocator: &mut Allocator<'_>, requirements: &MemoryRequirements, options: &AllocationCreateInfo<'_>, count: usize, ) -> Result<Vec<Allocation>, AllocError>
Allocate identical ordinary requirement pages; failure releases new pages only.

Contract

Allocate identical ordinary requirement pages; failure releases new pages only.

Host result storage is reserved before native effects. Generations may advance after rollback, and normal pool caching policy may retain empty native blocks.

Errors

Preserves allocation failure; rejects impossible result extents/serial overflow first.

Safety

Same raw requirements/feature/lifetime contract as allocate_with_options.

Fnvk::mem::allocate_with_options

pub unsafe fn allocate_with_options( allocator: &mut Allocator<'_>, requirements: &MemoryRequirements, options: &AllocationCreateInfo<'_>, ) -> Result<Allocation, AllocError>
Allocate unbound ordinary storage from native requirements with explicit policy.

Contract

Allocate unbound ordinary storage from native requirements with explicit policy.

Supports separate, adaptive and default/custom TLSF/linear pools. Unclassified pooled regions conflict with every native class (including themselves) on a granularity page. Actual offset satisfies native, minimum, pool and atom alignment. Persistent mapping, BDA flags, limits and rollback share the managed path.

Errors

Reports invalid requirements/policy, incompatible type, pool identity, limits, placement, bookkeeping or native errors. Mapping failure releases only new storage.

Safety

Requirements/physical metadata must be valid for this device. Imports use a validated AllocationChain; size/type-overriding payloads additionally require truthful ImportMemoryInfo. Its resource supplies any required dedication; without it, required native resource dedication remains excluded. Sparse, disjoint, capture/replay and tile semantics remain excluded. Protected memory requires captured enablement; aliases require can_alias and explicit native lifetime management. Complete every access and destroy bound resources before release. Bind once through checked helpers; raw pointer and GPU lifetimes remain caller-owned.

Fnvk::mem::allocation_info

pub fn allocation_info( allocator: &Allocator<'_>, allocation: &Allocation, ) -> Result<AllocationInfo, AllocError>
Snapshot one live allocation’s binding, actual properties and current mapping.

Contract

Snapshot one live allocation’s binding, actual properties and current mapping.

Donor: pinned VMA GetAllocationInfo and vmaGetAllocationMemoryProperties. Adaptation: checked owner/generation, one typed snapshot and per-region map holds. Performs no native query, mapping, allocation or synchronization. A pooled neighbor’s mapping does not expose a pointer for an unmapped region.

Errors

Returns Closed, WrongAllocator or UnknownAllocation before observing stale state.

Fnvk::mem::allocation_name

pub fn allocation_name<'a>( allocator: &'a Allocator<'_>, allocation: &Allocation, ) -> Result<Option<&'a str>, AllocError>
Borrow an allocation’s diagnostic name; no native lifetime is acquired.

Contract

Borrow an allocation’s diagnostic name; no native lifetime is acquired.

Fnvk::mem::allocator_info

Contract

Observe captured native identities without inferring manually omitted parent metadata.