Class VmaAllocatorCreateInfo

  • All Implemented Interfaces:
    java.lang.AutoCloseable, NativeResource, Pointer

    public class VmaAllocatorCreateInfo
    extends Struct
    implements NativeResource
    Description of an Allocator to be created.

    Member documentation

    • flags – flags for created allocator. Use VmaAllocatorCreateFlagBits enum. One of:
    • physicalDevice – Vulkan physical device. It must be valid throughout whole lifetime of created allocator.
    • device – Vulkan device. It must be valid throughout whole lifetime of created allocator.
    • preferredLargeHeapBlockSize – preferred size of a single VkDeviceMemory block to be allocated from large heaps > 1 GiB. Set to 0 to use default, which is currently 256 MiB. Optional.
    • pAllocationCallbacks – custom CPU memory allocation callbacks. Optional, can be null. When specified, will also be used for all CPU-side memory allocations. Optional.
    • pDeviceMemoryCallbacks – informative callbacks for vkAllocateMemory, vkFreeMemory. Optional.
    • frameInUseCount – Maximum number of additional frames that are in use at the same time as current frame.

      This value is used only when you make allocations with ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag. Such allocation cannot become lost if allocation.lastUseFrameIndex >= allocator.currentFrameIndex - frameInUseCount.

      For example, if you double-buffer your command buffers, so resources used for rendering in previous frame may still be in use by the GPU at the moment you allocate resources needed for the current frame, set this value to 1.

      If you want to allow any allocations other than used in the current frame to become lost, set this value to 0.

    • pHeapSizeLimit – Either NULL or a pointer to an array of limits on maximum number of bytes that can be allocated out of particular Vulkan memory heap.

      If not NULL, it must be a pointer to an array of VkPhysicalDeviceMemoryProperties::memoryHeapCount elements, defining limit on maximum number of bytes that can be allocated out of particular Vulkan memory heap.

      Any of the elements may be equal to VK_WHOLE_SIZE, which means no limit on that heap. This is also the default in case of pHeapSizeLimit = NULL.

      If there is a limit defined for a heap:

      • If user tries to allocate more memory from that heap using this allocator, the allocation fails with VK_ERROR_OUT_OF_DEVICE_MEMORY.
      • If the limit is smaller than heap size reported in VkMemoryHeap::size, the value of this limit will be reported instead when using GetMemoryProperties.

      Warning! Using this feature may not be equivalent to installing a GPU with smaller amount of memory, because graphics driver doesn't necessary fail new allocations with VK_ERROR_OUT_OF_DEVICE_MEMORY result when memory capacity is exceeded. It may return success and just silently migrate some device memory blocks to system RAM. This driver behavior can also be controlled using VK_AMD_memory_overallocation_behavior extension.

    • pVulkanFunctions – pointers to Vulkan functions
    • pRecordSettings – parameters for recording of VMA calls. Can be null.

      If not null, it enables recording of calls to VMA functions to a file. If support for recording is not enabled using VMA_RECORDING_ENABLED macro, creation of the allocator object fails with VK_ERROR_FEATURE_NOT_PRESENT.


     struct VmaAllocatorCreateInfo {
         VmaAllocatorCreateFlags flags;
         VkPhysicalDevice physicalDevice;
         VkDevice device;
         VkDeviceSize preferredLargeHeapBlockSize;
         VkAllocationCallbacks const * pAllocationCallbacks;
         VmaDeviceMemoryCallbacks const * pDeviceMemoryCallbacks;
         uint32_t frameInUseCount;
         VkDeviceSize const * pHeapSizeLimit;
         VmaVulkanFunctions const * pVulkanFunctions;
         VmaRecordSettings const * pRecordSettings;
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.

        The struct member offsets.
    • Constructor Detail

      • VmaAllocatorCreateInfo

        public VmaAllocatorCreateInfo​(java.nio.ByteBuffer container)
        Creates a VmaAllocatorCreateInfo instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

        The created instance holds a strong reference to the container object.

    • Method Detail

      • sizeof

        public int sizeof()
        Description copied from class: Struct
        Returns sizeof(struct).
        Specified by:
        sizeof in class Struct
      • flags

        public int flags()
        Returns the value of the flags field.
      • physicalDevice

        public long physicalDevice()
        Returns the value of the physicalDevice field.
      • device

        public long device()
        Returns the value of the device field.
      • preferredLargeHeapBlockSize

        public long preferredLargeHeapBlockSize()
        Returns the value of the preferredLargeHeapBlockSize field.
      • frameInUseCount

        public int frameInUseCount()
        Returns the value of the frameInUseCount field.
      • pHeapSizeLimit

        public java.nio.LongBuffer pHeapSizeLimit​(int capacity)
        Returns a LongBuffer view of the data pointed to by the pHeapSizeLimit field.
        capacity - the number of elements in the returned buffer
      • preferredLargeHeapBlockSize

        public VmaAllocatorCreateInfo preferredLargeHeapBlockSize​(long value)
        Sets the specified value to the preferredLargeHeapBlockSize field.
      • frameInUseCount

        public VmaAllocatorCreateInfo frameInUseCount​(int value)
        Sets the specified value to the frameInUseCount field.
      • pHeapSizeLimit

        public VmaAllocatorCreateInfo pHeapSizeLimit​(@Nullable
                                                     java.nio.LongBuffer value)
        Sets the address of the specified LongBuffer to the pHeapSizeLimit field.
      • malloc

        public static VmaAllocatorCreateInfo malloc()
        Returns a new VmaAllocatorCreateInfo instance allocated with memAlloc. The instance must be explicitly freed.
      • calloc

        public static VmaAllocatorCreateInfo calloc()
        Returns a new VmaAllocatorCreateInfo instance allocated with memCalloc. The instance must be explicitly freed.
      • create

        public static VmaAllocatorCreateInfo create​(long address)
        Returns a new VmaAllocatorCreateInfo instance for the specified memory address.
      • createSafe

        public static VmaAllocatorCreateInfo createSafe​(long address)
        Like create, but returns null if address is NULL.
      • callocStack

        public static VmaAllocatorCreateInfo callocStack()
        Returns a new VmaAllocatorCreateInfo instance allocated on the thread-local MemoryStack and initializes all its bits to zero.
      • mallocStack

        public static VmaAllocatorCreateInfo mallocStack​(MemoryStack stack)
        Returns a new VmaAllocatorCreateInfo instance allocated on the specified MemoryStack.
        stack - the stack from which to allocate
      • callocStack

        public static VmaAllocatorCreateInfo callocStack​(MemoryStack stack)
        Returns a new VmaAllocatorCreateInfo instance allocated on the specified MemoryStack and initializes all its bits to zero.
        stack - the stack from which to allocate
      • nflags

        public static int nflags​(long struct)
        Unsafe version of flags().
      • nphysicalDevice

        public static long nphysicalDevice​(long struct)
        Unsafe version of physicalDevice().
      • ndevice

        public static long ndevice​(long struct)
        Unsafe version of device().
      • npreferredLargeHeapBlockSize

        public static long npreferredLargeHeapBlockSize​(long struct)
      • nframeInUseCount

        public static int nframeInUseCount​(long struct)
        Unsafe version of frameInUseCount().
      • npHeapSizeLimit

        public static java.nio.LongBuffer npHeapSizeLimit​(long struct,
                                                          int capacity)
        Unsafe version of pHeapSizeLimit.
      • nflags

        public static void nflags​(long struct,
                                  int value)
        Unsafe version of flags.
      • ndevice

        public static void ndevice​(long struct,
                                   VkDevice value)
        Unsafe version of device.
      • npreferredLargeHeapBlockSize

        public static void npreferredLargeHeapBlockSize​(long struct,
                                                        long value)
        Unsafe version of preferredLargeHeapBlockSize.
      • nframeInUseCount

        public static void nframeInUseCount​(long struct,
                                            int value)
        Unsafe version of frameInUseCount.
      • npHeapSizeLimit

        public static void npHeapSizeLimit​(long struct,
                                           java.nio.LongBuffer value)
        Unsafe version of pHeapSizeLimit.
      • validate

        public static void validate​(long struct)
        Validates pointer members that should not be NULL.
        struct - the struct to validate
      • validate

        public static void validate​(long array,
                                    int count)
        Calls validate(long) for each struct contained in the specified struct array.
        array - the struct array to validate
        count - the number of structs in array