VulkanFrameAllocator
final class VulkanFrameAllocator
Package: dev.joid.backend.vulkan.render.buffer · Module: backend-vulkan · Source: VulkanFrameAllocator.java
Backends: Vulkan
Hands out aligned ranges of one buffer for the vertices or the uniforms of a frame, reset when the slot of the frame comes back.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| VulkanFrameAllocator(VulkanContext context, long capacity, int usage, long alignment, Consumer | Creates the allocator with a buffer of that capacity in bytes, that usage and that alignment; the consumer defers the destruction of a buffer that grew. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | destroy() | Destroys the current buffer. |
long | allocate(long size) | Returns the offset of an aligned range of that size in the current buffer. |
void | reset() | Makes the whole buffer free again, at the start of a frame of its slot. |
int | getUsage() | Returns the usage of the buffers. |
long | getAlignment() | Returns the alignment of the offsets, in bytes. |
VulkanContext | getContext() | Returns the device context. |
Consumer<Runnable> | getDisposer() | Returns the consumer that defers the destruction of a replaced buffer. |
long | getOffset() | Returns the first free byte of the current buffer. |
VulkanBuffer | getBuffer() | Returns the current buffer. |
Creation details
Section titled “Creation details”VulkanFrameAllocator
Section titled “VulkanFrameAllocator”VulkanFrameAllocator(VulkanContext context, long capacity, int usage, long alignment, Consumer<Runnable> disposer)
Creates the allocator with a buffer of that capacity in bytes, that usage and that alignment; the consumer defers the destruction of a buffer that grew.
Method details
Section titled “Method details”destroy
Section titled “destroy”void destroy()
Destroys the current buffer.
allocate
Section titled “allocate”long allocate(long size)
Returns the offset of an aligned range of that size in the current buffer.
When the buffer is full, it replaces it with a buffer twice as large, defers the destruction of the old one, and returns 0.
void reset()
Makes the whole buffer free again, at the start of a frame of its slot.
getUsage
Section titled “getUsage”int getUsage()
Returns the usage of the buffers.
getAlignment
Section titled “getAlignment”long getAlignment()
Returns the alignment of the offsets, in bytes.
getContext
Section titled “getContext”VulkanContext getContext()
Returns the device context.
getDisposer
Section titled “getDisposer”Consumer<Runnable> getDisposer()
Returns the consumer that defers the destruction of a replaced buffer.
getOffset
Section titled “getOffset”long getOffset()
Returns the first free byte of the current buffer.
getBuffer
Section titled “getBuffer”VulkanBuffer getBuffer()
Returns the current buffer.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
