Class DrawBufferManager

java.lang.Object
icyllis.arc3d.granite.DrawBufferManager

public class DrawBufferManager extends Object
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 Details

    • VERTEX_BUFFER_SIZE

      public static final int VERTEX_BUFFER_SIZE
      We 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

  • Method Details

    • getVertexPointer

      public long getVertexPointer(int requiredBytes, BufferViewInfo outInfo)
      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) * count
      outInfo - buffer bind info
      Returns:
      write-only address, or NULL
    • getUniformPointer

      public long getUniformPointer(int requiredBytes, BufferViewInfo outInfo)
      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) * count
      outInfo - 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

      public void flush(Consumer<@SharedPtr Task> outTasks, List<@SharedPtr Resource> outResourceRefs)
      Finalizes all buffers and transfers ownership of them to given list. Should not call if hasMappingFailed() returns true.
      Parameters:
      outTasks - receive tasks
      outResourceRefs - receive ownership of resources