Class StreamBuffer
java.lang.Object
lol.trq.helios.gl.StreamBuffer
- All Implemented Interfaces:
AutoCloseable
Streamed vertex data, the one place that decides how per-frame uploads reach the GPU.
The strategy keeps a ring of array buffers. Each frame appends its data to one buffer, so no upload touches a
region the GPU may still be reading. The write itself is glBufferSubData by default, or an unsynchronized
glMapBufferRange with -Dhelios.stream=map; the fences make the mapping safe. endFrame() fences the
buffer and moves to the next, waiting on that one's fence from ring frames ago (normally long signalled). A
frame that outgrows its buffer orphans it and starts again at offset 0.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBuffers in the ring.static final String-Dhelios.stream:subdata(default) ormap. -
Constructor Summary
ConstructorsConstructorDescriptionStreamBuffer(GlBackend gl, long capacity) Creates the ring lazily on first use. -
Method Summary
Modifier and TypeMethodDescriptionintbuffer()Returns the buffer the last upload went to.voidclose()Deletes the buffers and fences.voidendFrame()Fences this frame's buffer and moves to the next, waiting until the GPU has finished with it.intorphans()Returns how often a frame outgrew its buffer and orphaned it.longupload(ByteBuffer data, int alignment) Uploads data into the current buffer and leaves it bound toGlBackend.ARRAY_BUFFER.
-
Field Details
-
RING
public static final int RINGBuffers in the ring.- See Also:
-
STRATEGY_PROPERTY
-
-
Constructor Details
-
StreamBuffer
Creates the ring lazily on first use.- Parameters:
gl- the backendcapacity- bytes per buffer
-
-
Method Details
-
upload
Uploads data into the current buffer and leaves it bound toGlBackend.ARRAY_BUFFER.- Parameters:
data- the bytes, from position to limit; at most the capacityalignment- the start offset is a multiple of this, such as the vertex stride- Returns:
- the byte offset the data starts at
-
buffer
public int buffer()Returns the buffer the last upload went to.- Returns:
- the buffer name, 0 before the first upload
-
endFrame
public void endFrame()Fences this frame's buffer and moves to the next, waiting until the GPU has finished with it. -
orphans
public int orphans()Returns how often a frame outgrew its buffer and orphaned it.- Returns:
- the count since creation
-
close
-