Class VmaBudget

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

    public class VmaBudget
    extends org.lwjgl.system.Struct
    implements org.lwjgl.system.NativeResource
    Statistics of current memory usage and available budget, in bytes, for specific memory heap.

    Member documentation

    • blockBytes – Sum size of all VkDeviceMemory blocks allocated from particular heap, in bytes.
    • allocationBytes – Sum size of all allocations created in particular heap, in bytes.

      Usually less or equal than blockBytes. Difference blockBytes - allocationBytes is the amount of memory allocated but unused - available for new allocations or wasted due to fragmentation.

      It might be greater than blockBytes if there are some allocations in lost state, as they account to this value as well.

    • usage – Estimated current memory usage of the program, in bytes.

      Fetched from system using VK_EXT_memory_budget extension if enabled.

      It might be different than blockBytes (usually higher) due to additional implicit objects also occupying the memory, like swapchain, pipelines, descriptor heaps, command buffers, or VkDeviceMemory blocks allocated outside of this library, if any.

    • budget – Estimated amount of memory available to the program, in bytes.

      Fetched from system using VK_EXT_memory_budget extension if enabled.

      It might be different (most probably smaller) than VkMemoryHeap::size[heapIndex] due to factors external to the program, like other programs also consuming system resources. Difference budget - usage is the amount of additional memory that can probably be allocated without problems. Exceeding the budget may result in various problems.

    Layout

    
     struct VmaBudget {
         VkDeviceSize blockBytes;
         VkDeviceSize allocationBytes;
         VkDeviceSize usage;
         VkDeviceSize budget;
     }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  VmaBudget.Buffer
      An array of VmaBudget structs.
      • Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer

        org.lwjgl.system.Pointer.Default
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALIGNOF
      The struct alignment in bytes.
      static int ALLOCATIONBYTES
      BLOCKBYTES
      BUDGET
      The struct member offsets.
      static int SIZEOF
      The struct size in bytes.
      static int USAGE
      The struct member offsets.
      • Fields inherited from interface org.lwjgl.system.Pointer

        BITS32, BITS64, CLONG_SHIFT, CLONG_SIZE, POINTER_SHIFT, POINTER_SIZE
    • Constructor Summary

      Constructors 
      Constructor Description
      VmaBudget​(java.nio.ByteBuffer container)
      Creates a VmaBudget instance at the current position of the specified ByteBuffer container.
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.
      • BLOCKBYTES, ALLOCATIONBYTES, USAGE, BUDGET

        The struct member offsets.
    • Constructor Detail

      • VmaBudget

        public VmaBudget​(java.nio.ByteBuffer container)
        Creates a VmaBudget 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()
        Specified by:
        sizeof in class org.lwjgl.system.Struct
      • blockBytes

        public long blockBytes()
        Returns the value of the blockBytes field.
      • allocationBytes

        public long allocationBytes()
        Returns the value of the allocationBytes field.
      • usage

        public long usage()
        Returns the value of the usage field.
      • budget

        public long budget()
        Returns the value of the budget field.
      • malloc

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

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

        public static VmaBudget create()
        Returns a new VmaBudget instance allocated with BufferUtils.
      • create

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

        @Nullable
        public static VmaBudget createSafe​(long address)
        Like create, but returns null if address is NULL.
      • malloc

        public static VmaBudget.Buffer malloc​(int capacity)
        Returns a new VmaBudget.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • calloc

        public static VmaBudget.Buffer calloc​(int capacity)
        Returns a new VmaBudget.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • create

        public static VmaBudget.Buffer create​(int capacity)
        Returns a new VmaBudget.Buffer instance allocated with BufferUtils.
        Parameters:
        capacity - the buffer capacity
      • create

        public static VmaBudget.Buffer create​(long address,
                                              int capacity)
        Create a VmaBudget.Buffer instance at the specified memory.
        Parameters:
        address - the memory address
        capacity - the buffer capacity
      • createSafe

        @Nullable
        public static VmaBudget.Buffer createSafe​(long address,
                                                  int capacity)
        Like create, but returns null if address is NULL.
      • mallocStack

        public static VmaBudget mallocStack()
        Returns a new VmaBudget instance allocated on the thread-local MemoryStack.
      • callocStack

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

        public static VmaBudget mallocStack​(org.lwjgl.system.MemoryStack stack)
        Returns a new VmaBudget instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
      • callocStack

        public static VmaBudget callocStack​(org.lwjgl.system.MemoryStack stack)
        Returns a new VmaBudget instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
      • mallocStack

        public static VmaBudget.Buffer mallocStack​(int capacity)
        Returns a new VmaBudget.Buffer instance allocated on the thread-local MemoryStack.
        Parameters:
        capacity - the buffer capacity
      • callocStack

        public static VmaBudget.Buffer callocStack​(int capacity)
        Returns a new VmaBudget.Buffer instance allocated on the thread-local MemoryStack and initializes all its bits to zero.
        Parameters:
        capacity - the buffer capacity
      • mallocStack

        public static VmaBudget.Buffer mallocStack​(int capacity,
                                                   org.lwjgl.system.MemoryStack stack)
        Returns a new VmaBudget.Buffer instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • callocStack

        public static VmaBudget.Buffer callocStack​(int capacity,
                                                   org.lwjgl.system.MemoryStack stack)
        Returns a new VmaBudget.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • nblockBytes

        public static long nblockBytes​(long struct)
        Unsafe version of blockBytes().
      • nallocationBytes

        public static long nallocationBytes​(long struct)
        Unsafe version of allocationBytes().
      • nusage

        public static long nusage​(long struct)
        Unsafe version of usage().
      • nbudget

        public static long nbudget​(long struct)
        Unsafe version of budget().