Realm

vk::mem · Functions · F1

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

FnRustExperimental

Fnvk::mem::find_memory_type

pub fn find_memory_type( allocator: &Allocator<'_>, memory_type_bits: u32, options: &AllocationCreateInfo<'_>, ) -> Result<u32, AllocError>
Select from explicit native memory-type bits without allocating or querying a budget.

Contract

Select from explicit native memory-type bits without allocating or querying a budget.

Pool identity/type, masks and mandatory properties remain checked. This does not reserve storage or promise allocation success. Automatic usage requires a creation-info query instead. Zero mask means no compatible type.

Errors

Returns closed/pool identity, unsupported policy or incompatible-type errors.

Fnvk::mem::find_memory_type_for_buffer_info

pub unsafe fn find_memory_type_for_buffer_info( allocator: &Allocator<'_>, info: &BufferCreateInfo<'_>, options: &AllocationCreateInfo<'_>, ) -> Result<u32, AllocError>
Select memory for an ordinary buffer using its actual creation usage and requirements.

Contract

Select memory for an ordinary buffer using its actual creation usage and requirements.

Core 1.3 or enabled KHR maintenance4 queries without creating a resource. Older versions create/query/destroy one temporary unbound buffer. No memory is allocated, mapped or bound; allocator accounting and live tokens stay unchanged. This is type selection, not an allocation/budget guarantee.

Errors

Reports invalid/unsupported creation policy, missing exact PFNs, native create failure or incompatible requirements/properties. Temporary resources are destroyed after successful creation even if requirement validation or selection fails.

Safety

Creation records/chains must satisfy enabled native valid usage and remain readable for this call; device metadata, callbacks and host synchronization must be valid.

Fnvk::mem::find_memory_type_for_image_info

pub unsafe fn find_memory_type_for_image_info( allocator: &Allocator<'_>, info: &ImageCreateInfo<'_>, options: &AllocationCreateInfo<'_>, ) -> Result<u32, AllocError>
Select memory for an ordinary non-disjoint image from creation usage and native requirements.

Contract

Select memory for an ordinary non-disjoint image from creation usage and native requirements.

Uses exact core/KHR maintenance4 when admitted, otherwise a temporary unbound image with preflighted cleanup. No allocation/binding/mapping or budget query occurs.

Errors

Same policy, identity, missing-command, native creation and compatibility errors as find_memory_type_for_buffer_info; all created temporaries are cleaned up.

Safety

Image/format/feature, chain, callback and host synchronization valid usage must hold for the complete call. Sparse/disjoint/DRM/external paths are excluded; protected queries require captured enablement.

Fnvk::mem::flush

pub unsafe fn flush( allocator: &Allocator<'_>, allocation: &Allocation, offset: u64, size: u64, ) -> Result<(), AllocError>
Flush a bounded allocation-relative mapped range, observing atom/end rules.

Contract

Flush a bounded allocation-relative mapped range, observing atom/end rules.

Safety

Follow Vulkan’s host/device synchronization and mapping requirements.

Fnvk::mem::flush_many

pub unsafe fn flush_many( allocator: &Allocator<'_>, ranges: &[CacheRange<'_>], ) -> Result<(), AllocError>
Flush checked ranges in one native call; coherent/empty ranges remain checked no-ops.

Contract

Flush checked ranges in one native call; coherent/empty ranges remain checked no-ops.

Errors

Invalid identity/map/range or host reservation fails before the native call.

Safety

Match Vulkan host/GPU synchronization and host-write visibility requirements.

Fnvk::mem::free

Contract

Release a separate allocation or pooled placement and invalidate its token.

Safety

Destroy all bound resources and complete every host/GPU access first. This is also the low-level escape route after manually destroying a managed buffer.

Fnvk::mem::free_many

Contract

Validate an entire release batch before freeing any allocation.

Successful release invalidates every token. Ordinary native cleanup uses immutable preflighted void PFNs; no host allocation is needed for this batch.

Errors

Rejects closed, foreign, stale, duplicate or explicitly mapped tokens before effects.

Safety

Every bound resource must already be destroyed and every CPU/GPU use complete.