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 Details

    • DEFAULT_BUFFER_SIZE

      public static final int DEFAULT_BUFFER_SIZE
      Deprecated.
      We expect buffers for meshes to be at least 128KB.
      See Also:
    • 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: 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: 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.