Package icyllis.arc3d.engine
Class GpuBufferPool
java.lang.Object
icyllis.arc3d.engine.GpuBufferPool
Deprecated.
A pool of geometry buffers tied to a
Device
.
The pool allows a client to make space for geometry and then put back excess
space if it over allocated. When a client is ready to draw from the pool
it calls flush()
on the pool ensure buffers are ready for drawing.
The pool can be reset after drawing is completed to recycle space. After that,
all GPU buffers can't be touched again (imagine we have triple buffering).
At creation time a minimum per-buffer size can be specified. Additionally, a number of buffers to pre-allocate can be specified. These will be allocated at the minimum size and kept around until the pool is destroyed.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Deprecated.We expect buffers for meshes to be at least 128KB.protected long
Deprecated.protected @SharedPtr Buffer[]
Deprecated.protected ByteBuffer
Deprecated.protected int[]
Deprecated.protected int
Deprecated. -
Constructor Summary
ModifierConstructorDescriptionprotected
GpuBufferPool
(ResourceProvider resourceProvider, int bufferType) Deprecated.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Deprecated.Ensures all buffers are unlocked and have all data written to them.static GpuBufferPool
makeIndexPool
(ResourceProvider resourceProvider) Deprecated.Constructor.static GpuBufferPool
makeInstancePool
(ResourceProvider resourceProvider) Deprecated.Constructor.protected long
makeSpace
(int size, int alignment) Deprecated.Returns a block of memory to hold data.abstract long
Deprecated.Returns a block of memory to hold vertices/instances/indices.static GpuBufferPool
makeVertexPool
(ResourceProvider resourceProvider) Deprecated.Constructor.abstract ByteBuffer
makeWriter
(Mesh mesh) Deprecated.Similar tomakeSpace(Mesh)
, but returns a wrapper instead.void
putBack
(int bytes) Deprecated.Frees data from makeSpaces in LIFO order.void
reset()
Deprecated.Invalidates all the data in the pool, unrefs non-pre-allocated buffers.void
submit
(CommandBuffer cmdBuffer) Deprecated.Alternative toreset()
that flushes and submits ALL using buffers to the given command buffer.
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEDeprecated.We expect buffers for meshes to be at least 128KB.- See Also:
-
mBuffers
Deprecated. -
mFreeBytes
protected int[] mFreeBytesDeprecated. -
mIndex
protected int mIndexDeprecated. -
mBufferPtr
protected long mBufferPtrDeprecated. -
mCachedWriter
Deprecated.
-
-
Constructor Details
-
GpuBufferPool
Deprecated.Constructor.- Parameters:
resourceProvider
- the factory used to create the buffers.bufferType
- the type of buffers to create.
-
-
Method Details
-
makeVertexPool
Deprecated.Constructor.- Parameters:
resourceProvider
- the factory used to create the vertex buffers.
-
makeInstancePool
Deprecated.Constructor.- Parameters:
resourceProvider
- the factory used to create the instance buffers.
-
makeIndexPool
Deprecated.Constructor.- Parameters:
resourceProvider
- the factory used to create the index buffers.
-
flush
public void flush()Deprecated.Ensures all buffers are unlocked and have all data written to them. Call before drawing using buffers from the pool. -
reset
public void reset()Deprecated.Invalidates all the data in the pool, unrefs non-pre-allocated buffers. This should be called at the end of each frame and destructor. -
submit
Deprecated.Alternative toreset()
that flushes and submits ALL using buffers to the given command buffer. This method ensures all buffers are unlocked and have all data written to them.- Parameters:
cmdBuffer
- the cmd buf the G buffers used in
-
putBack
public void putBack(int bytes) Deprecated.Frees data from makeSpaces in LIFO order. -
makeSpace
Deprecated.Returns a block of memory to hold vertices/instances/indices. A buffer designated to hold the vertices/instances/indices given to the caller. The buffer may or may not be locked. The returned ptr remains valid until any of the following: Onceflush()
on the pool is called the vertices/instances/indices are guaranteed to be in the buffer at the offset indicated by baseVertex/ baseInstance/firstIndex. Until that time they may be in temporary storage and/or the buffer may be locked.- Parameters:
mesh
- specifies the mesh to allocate space for- Returns:
- pointer to first vertex/instance/index, or NULL if failed
-
makeWriter
Deprecated.Similar tomakeSpace(Mesh)
, but returns a wrapper instead.- Parameters:
mesh
- specifies the mesh to allocate space for- Returns:
- pointer to first vertex/instance/index, or null if failed
-
makeSpace
protected long makeSpace(int size, int alignment) Deprecated.Returns a block of memory to hold data. A buffer designated to hold the data is given to the caller. The buffer may or may not be locked. The returned ptr remains valid until any of the following: Onceflush()
on the pool is called the data is guaranteed to be in the buffer at the offset indicated by offset. Until that time it may be in temporary storage and/or the buffer may be locked.- Parameters:
size
- the amount of data to make space foralignment
- alignment constraint from start of buffer- Returns:
- pointer to where the client should write the data, may be nullptr.
-