Package icyllis.arc3d.engine

# Class GpuBufferPool

java.lang.Object
icyllis.arc3d.engine.GpuBufferPool

@Deprecated public abstract class GpuBufferPool extends Object
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

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `DEFAULT_BUFFER_SIZE`
  Deprecated.
  We expect buffers for meshes to be at least 128KB.
  `protected long`
  `mBufferPtr`
  Deprecated.
  `protected @SharedPtr Buffer[]`
  `mBuffers`
  Deprecated.
  `protected ByteBuffer`
  `mCachedWriter`
  Deprecated.
  `protected int[]`
  `mFreeBytes`
  Deprecated.
  `protected int`
  `mIndex`
  Deprecated.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `GpuBufferPool(ResourceProvider resourceProvider, int bufferType)`
  Deprecated.
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `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`
  `makeSpace(Mesh mesh)`
  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 to `makeSpace(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 to `reset()` that flushes and submits ALL using buffers to the given command buffer.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_BUFFER_SIZE

    public static final int DEFAULT_BUFFER_SIZE
    Deprecated.
    We expect buffers for meshes to be at least 128KB.
    See Also:
      - Constant Field Values

  - ### mBuffers

    @SharedPtr protected @SharedPtr Buffer[] mBuffers
    Deprecated.

  - ### mFreeBytes

    protected int[] mFreeBytes
    Deprecated.

  - ### mIndex

    protected int mIndex
    Deprecated.

  - ### mBufferPtr

    protected long mBufferPtr
    Deprecated.

  - ### mCachedWriter

    protected ByteBuffer mCachedWriter
    Deprecated.

- ## Constructor Details

  - ### GpuBufferPool

    protected GpuBufferPool(ResourceProvider resourceProvider, int bufferType)
    Deprecated.
    Constructor.
    Parameters:
      `resourceProvider` - the factory used to create the buffers.
      `bufferType` - the type of buffers to create.

- ## Method Details

  - ### makeVertexPool

    @Nonnull public static GpuBufferPool makeVertexPool(ResourceProvider resourceProvider)
    Deprecated.
    Constructor.
    Parameters:
      `resourceProvider` - the factory used to create the vertex buffers.

  - ### makeInstancePool

    @Nonnull public static GpuBufferPool makeInstancePool(ResourceProvider resourceProvider)
    Deprecated.
    Constructor.
    Parameters:
      `resourceProvider` - the factory used to create the instance buffers.

  - ### makeIndexPool

    @Nonnull public static GpuBufferPool makeIndexPool(ResourceProvider resourceProvider)
    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

    public void submit(CommandBuffer cmdBuffer)
    Deprecated.
    Alternative to `reset()` 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

    public abstract long makeSpace(Mesh mesh)
    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:
    - this method is called again.
    - `flush()` is called.
    - `reset()` is called.
    Once `flush()` 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

    @Nullable public abstract ByteBuffer makeWriter(Mesh mesh)
    Deprecated.
    Similar to `makeSpace(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:
    - this method is called again.
    - `flush()` is called.
    - `reset()` is called.
    Once `flush()` 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 for
      `alignment` - alignment constraint from start of buffer
    Returns:
      pointer to where the client should write the data, may be nullptr.