Interface StreamingBuffer

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
GlStreamingBuffer, WgpuStreamingBuffer

public interface StreamingBuffer extends AutoCloseable
A streaming buffer for per-frame data uploads.

Uses triple-buffering internally: while the GPU reads from one region, the CPU writes to another. Fences ensure no overlap.

Backend-specific implementations use persistent mapping (GL) or staging buffers (Vulkan/WebGPU).

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Advances to the next frame.
    Begins writing for the current frame.
    void
     
    long
    Returns the byte offset into the buffer for the current frame's data.
    void
    Finishes writing.
    long
    Size of a single frame's region.
    The underlying GPU buffer handle.
    long
    Total buffer size in bytes.
  • Method Details

    • handle

      The underlying GPU buffer handle.
    • size

      long size()
      Total buffer size in bytes.
    • frameSize

      long frameSize()
      Size of a single frame's region.
    • beginWrite

      NativeMemory beginWrite()
      Begins writing for the current frame. Returns a NativeMemory pointing to the current frame's region. The memory is valid until endWrite() is called.
    • endWrite

      void endWrite()
      Finishes writing. The data becomes available to the GPU.
    • currentOffset

      long currentOffset()
      Returns the byte offset into the buffer for the current frame's data. Use this for glBindBufferRange offset.
    • advance

      void advance()
      Advances to the next frame. Must be called once per frame.
    • close

      void close()
      Specified by:
      close in interface AutoCloseable