Struct vulkan_malloc::Allocator [] [src]

pub struct Allocator { /* fields omitted */ }

Thread-safe device memory allocator

See top-level crate documentation for more detail and examples.

Methods

impl Allocator
[src]

Creates a builder for creating an Allocator.

Simple usage:

let allocator = Allocator::builder(device, physical_device).build();

This algorithm tries to find a memory type that:

  • Is allowed by memoryTypeBits.
  • Contains all the flags from pMemoryRequirements->requiredFlags.
  • Matches intended usage.
  • Has as many flags from pMemoryRequirements->preferredFlags as possible.

Returns Error::FeatureNotPresent if not found. Receiving such result from this function or any other allocating function probably means that your device doesn't support any memory type with requested features for the specific type of resource you want to use it for. Please check parameters of your resource, like image layout (OPTIMAL versus LINEAR) or mip level count.

Frees memory previously allocated using allocate or allocate_for_buffer or allocate_for_image.

General purpose memory allocation.

Memory allocated with this function should be freed using free.

It is recommended to use allocate_for_buffer, allocate_for_image, create_buffer, create_image instead whenever possible.

Memory allocated with this function should be freed using free.

Memory allocated with this function should be freed using free.

This function automatically:

  • Creates a buffer.
  • Allocates appropriate memory for it.
  • Binds the buffer with the memory.

Make sure to call free_buffer when finished with the returned buffer. Do not use free.

Frees internal resources and memory for a buffer created by create_buffer.

This function automatically:

  • Creates an image.
  • Allocates appropriate memory for it.
  • Binds the image with the memory.

Make sure to call free_image when finished with the returned image. Do not use free.

Frees internal resources and memory for an image created by create_image.

Feel free to use DeviceMemory::map on your own if you want, but just for convenience and to make sure correct offset and size is always specified, usage of map_memory is recommended.