Class VmaBudget
- java.lang.Object
-
- org.lwjgl.system.Pointer.Default
-
- org.lwjgl.system.Struct
-
- org.lwjgl.util.vma.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 allVkDeviceMemory
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
. DifferenceblockBytes - 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, orVkDeviceMemory
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. Differencebudget - 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 ofVmaBudget
structs.
-
Field Summary
Fields Modifier and Type Field Description static int
ALIGNOF
The struct alignment in bytes.static int
ALLOCATIONBYTES
BLOCKBYTES
BUDGETThe struct member offsets.static int
SIZEOF
The struct size in bytes.static int
USAGE
The struct member offsets.
-
Constructor Summary
Constructors Constructor Description VmaBudget(java.nio.ByteBuffer container)
Creates aVmaBudget
instance at the current position of the specifiedByteBuffer
container.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
allocationBytes()
Returns the value of theallocationBytes
field.long
blockBytes()
Returns the value of theblockBytes
field.long
budget()
Returns the value of thebudget
field.static VmaBudget
calloc()
Returns a newVmaBudget
instance allocated withmemCalloc
.static VmaBudget.Buffer
calloc(int capacity)
Returns a newVmaBudget.Buffer
instance allocated withmemCalloc
.static VmaBudget
callocStack()
Returns a newVmaBudget
instance allocated on the thread-localMemoryStack
and initializes all its bits to zero.static VmaBudget.Buffer
callocStack(int capacity)
Returns a newVmaBudget.Buffer
instance allocated on the thread-localMemoryStack
and initializes all its bits to zero.static VmaBudget.Buffer
callocStack(int capacity, org.lwjgl.system.MemoryStack stack)
Returns a newVmaBudget.Buffer
instance allocated on the specifiedMemoryStack
and initializes all its bits to zero.static VmaBudget
callocStack(org.lwjgl.system.MemoryStack stack)
Returns a newVmaBudget
instance allocated on the specifiedMemoryStack
and initializes all its bits to zero.static VmaBudget
create()
Returns a newVmaBudget
instance allocated withBufferUtils
.static VmaBudget.Buffer
create(int capacity)
Returns a newVmaBudget.Buffer
instance allocated withBufferUtils
.static VmaBudget
create(long address)
Returns a newVmaBudget
instance for the specified memory address.static VmaBudget.Buffer
create(long address, int capacity)
Create aVmaBudget.Buffer
instance at the specified memory.static VmaBudget
createSafe(long address)
static VmaBudget.Buffer
createSafe(long address, int capacity)
static VmaBudget
malloc()
Returns a newVmaBudget
instance allocated withmemAlloc
.static VmaBudget.Buffer
malloc(int capacity)
Returns a newVmaBudget.Buffer
instance allocated withmemAlloc
.static VmaBudget
mallocStack()
Returns a newVmaBudget
instance allocated on the thread-localMemoryStack
.static VmaBudget.Buffer
mallocStack(int capacity)
Returns a newVmaBudget.Buffer
instance allocated on the thread-localMemoryStack
.static VmaBudget.Buffer
mallocStack(int capacity, org.lwjgl.system.MemoryStack stack)
Returns a newVmaBudget.Buffer
instance allocated on the specifiedMemoryStack
.static VmaBudget
mallocStack(org.lwjgl.system.MemoryStack stack)
Returns a newVmaBudget
instance allocated on the specifiedMemoryStack
.static long
nallocationBytes(long struct)
Unsafe version ofallocationBytes()
.static long
nblockBytes(long struct)
Unsafe version ofblockBytes()
.static long
nbudget(long struct)
Unsafe version ofbudget()
.static long
nusage(long struct)
Unsafe version ofusage()
.int
sizeof()
long
usage()
Returns the value of theusage
field.
-
-
-
Constructor Detail
-
VmaBudget
public VmaBudget(java.nio.ByteBuffer container)
Creates aVmaBudget
instance at the current position of the specifiedByteBuffer
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 classorg.lwjgl.system.Struct
-
blockBytes
public long blockBytes()
Returns the value of theblockBytes
field.
-
allocationBytes
public long allocationBytes()
Returns the value of theallocationBytes
field.
-
usage
public long usage()
Returns the value of theusage
field.
-
budget
public long budget()
Returns the value of thebudget
field.
-
malloc
public static VmaBudget malloc()
Returns a newVmaBudget
instance allocated withmemAlloc
. The instance must be explicitly freed.
-
calloc
public static VmaBudget calloc()
Returns a newVmaBudget
instance allocated withmemCalloc
. The instance must be explicitly freed.
-
create
public static VmaBudget create()
Returns a newVmaBudget
instance allocated withBufferUtils
.
-
create
public static VmaBudget create(long address)
Returns a newVmaBudget
instance for the specified memory address.
-
createSafe
@Nullable public static VmaBudget createSafe(long address)
-
malloc
public static VmaBudget.Buffer malloc(int capacity)
Returns a newVmaBudget.Buffer
instance allocated withmemAlloc
. The instance must be explicitly freed.- Parameters:
capacity
- the buffer capacity
-
calloc
public static VmaBudget.Buffer calloc(int capacity)
Returns a newVmaBudget.Buffer
instance allocated withmemCalloc
. The instance must be explicitly freed.- Parameters:
capacity
- the buffer capacity
-
create
public static VmaBudget.Buffer create(int capacity)
Returns a newVmaBudget.Buffer
instance allocated withBufferUtils
.- Parameters:
capacity
- the buffer capacity
-
create
public static VmaBudget.Buffer create(long address, int capacity)
Create aVmaBudget.Buffer
instance at the specified memory.- Parameters:
address
- the memory addresscapacity
- the buffer capacity
-
createSafe
@Nullable public static VmaBudget.Buffer createSafe(long address, int capacity)
-
mallocStack
public static VmaBudget mallocStack()
Returns a newVmaBudget
instance allocated on the thread-localMemoryStack
.
-
callocStack
public static VmaBudget callocStack()
Returns a newVmaBudget
instance allocated on the thread-localMemoryStack
and initializes all its bits to zero.
-
mallocStack
public static VmaBudget mallocStack(org.lwjgl.system.MemoryStack stack)
Returns a newVmaBudget
instance allocated on the specifiedMemoryStack
.- Parameters:
stack
- the stack from which to allocate
-
callocStack
public static VmaBudget callocStack(org.lwjgl.system.MemoryStack stack)
Returns a newVmaBudget
instance allocated on the specifiedMemoryStack
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 newVmaBudget.Buffer
instance allocated on the thread-localMemoryStack
.- Parameters:
capacity
- the buffer capacity
-
callocStack
public static VmaBudget.Buffer callocStack(int capacity)
Returns a newVmaBudget.Buffer
instance allocated on the thread-localMemoryStack
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 newVmaBudget.Buffer
instance allocated on the specifiedMemoryStack
.- Parameters:
stack
- the stack from which to allocatecapacity
- the buffer capacity
-
callocStack
public static VmaBudget.Buffer callocStack(int capacity, org.lwjgl.system.MemoryStack stack)
Returns a newVmaBudget.Buffer
instance allocated on the specifiedMemoryStack
and initializes all its bits to zero.- Parameters:
stack
- the stack from which to allocatecapacity
- the buffer capacity
-
nblockBytes
public static long nblockBytes(long struct)
Unsafe version ofblockBytes()
.
-
nallocationBytes
public static long nallocationBytes(long struct)
Unsafe version ofallocationBytes()
.
-
nusage
public static long nusage(long struct)
Unsafe version ofusage()
.
-
nbudget
public static long nbudget(long struct)
Unsafe version ofbudget()
.
-
-