Package icyllis.arc3d.granite
Class DrawBufferManager
java.lang.Object
icyllis.arc3d.granite.DrawBufferManager
Manages dynamic and streaming GPU buffers.
This prefers to create a large ring buffer that is host visible and device visible. If not available, creates a large staging buffer and a device local buffer.
For streaming buffers: use persistent mapped host-visible buffers for Vulkan and OpenGL 4.4; use mutable buffer and CPU staging buffer for OpenGL 4.3 and below.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
We expect buffers for meshes to be at least 128KB. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
alignUniformBlockSize
(int dataSize) void
flush
(Consumer<@SharedPtr Task> outTasks, List<@SharedPtr Resource> outResourceRefs) Finalizes all buffers and transfers ownership of them to given list.long
getUniformPointer
(int requiredBytes, BufferViewInfo outInfo) Allocate write-combining buffer and return a host coherent memory address.long
getVertexPointer
(int requiredBytes, BufferViewInfo outInfo) Allocate write-combining buffer and return a host coherent memory address.boolean
void
putBackVertexBytes
(int unusedBytes)
-
Field Details
-
VERTEX_BUFFER_SIZE
public static final int VERTEX_BUFFER_SIZEWe expect buffers for meshes to be at least 128KB.- See Also:
-
INDEX_BUFFER_SIZE
public static final int INDEX_BUFFER_SIZE- See Also:
-
UNIFORM_BUFFER_SIZE
public static final int UNIFORM_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
DrawBufferManager
-
-
Method Details
-
getVertexPointer
Allocate write-combining buffer and return a host coherent memory address. Return pointer is 4-byte aligned, if NULL then allocation is failed.- Parameters:
requiredBytes
- vertex stride (4-byte aligned) * countoutInfo
- buffer bind info- Returns:
- write-only address, or NULL
-
getUniformPointer
Allocate write-combining buffer and return a host coherent memory address. The buffer can be used only for uniform buffer. Return pointer is 4-byte aligned according to GPU requirements, if NULL then allocation is failed.- Parameters:
requiredBytes
- uniform buffer size (aligned) * countoutInfo
- buffer bind info- Returns:
- write-only address, or NULL
- See Also:
-
putBackVertexBytes
public void putBackVertexBytes(int unusedBytes) -
alignUniformBlockSize
public int alignUniformBlockSize(int dataSize) -
hasMappingFailed
public boolean hasMappingFailed() -
flush
Finalizes all buffers and transfers ownership of them to given list. Should not call if hasMappingFailed() returns true.- Parameters:
outTasks
- receive tasksoutResourceRefs
- receive ownership of resources
-