Package cz.fidentis.analyst.glsl.buffers
Interface SsboBuffer
- All Superinterfaces:
GlslBuffer
- All Known Subinterfaces:
AtomicCounterBuffer
- All Known Implementing Classes:
AtomicCounterBufferImpl
,SsboBufferImpl
Shader Storage Buffer Object (SSBO) buffer, i.e., the
GL_SHADER_STORAGE_BUFFER
OpenGL target.-
Method Summary
Modifier and TypeMethodDescriptionvoid
allocate
(long items, boolean reset) Allocates memory for this SSBO buffer on GPU.void
allocate
(long items, long extraSpace, boolean reset) Allocates memory for this SSBO buffer on GPU.long
SSBO buffers typically store some amount of items of the same type (integers, floats, etc.).int
getUsage()
Returns buffer's usage typevoid
readFrom
(long offset, long items, Consumer<ByteBuffer> reader) Reads data from the buffer.void
writeBytesTo
(long offset, long size, Consumer<ByteBuffer> filler) Writes data to the buffer.void
writeItemsTo
(long offset, long numItems, Consumer<ByteBuffer> filler) Writes data to the buffer.Methods inherited from interface cz.fidentis.analyst.glsl.buffers.GlslBuffer
bind, getBindingIndex, getBufferName, getGlName, getGlTarget, glContext
-
Method Details
-
getUsage
int getUsage()Returns buffer's usage type- Returns:
- usage type
-
getItemSize
long getItemSize()SSBO buffers typically store some amount of items of the same type (integers, floats, etc.). This method returns the size (number of bytes) of a single item.- Returns:
- items' size
-
allocate
void allocate(long items, boolean reset) Allocates memory for this SSBO buffer on GPU. Can be used multiple times to resize the buffer. You can allocate space for unbound buffer and vice versa. Resulting buffer will occupyitems *
getItemSize()
bytes.- Parameters:
items
- how many items are going to be stored in the bufferreset
- iftrue
, then the buffer is filled with zeros
-
allocate
void allocate(long items, long extraSpace, boolean reset) Allocates memory for this SSBO buffer on GPU. Can be used multiple times to resize the buffer. You can allocate space for unbound buffer and vice versa. Resulting buffer will occpyitems *
getItemSize()
+ extraSpace
bytes.- Parameters:
items
- how many items are going to be stored in the buffer. Can be zero.extraSpace
- extra space. Can be zero.reset
- iftrue
, then the buffer is filled with zeros
-
writeItemsTo
Writes data to the buffer. The size of written data isnumItemes *
getItemSize()
. Buffer must be already allocated and have sufficient size, otherwise GL error is thrown.- Parameters:
offset
- numItems offset (numItems
to be skipped). Can be zeronumItems
- how many numItems we want to writefiller
- filler that writes data to the buffer
-
writeBytesTo
Writes data to the buffer. Buffer must be already allocated and have sufficient size, otherwise GL error is thrown.- Parameters:
offset
- number of bytes to be skipped. Can be zerosize
- how many bytes to writefiller
- filler that writes data to the buffer
-
readFrom
Reads data from the buffer. Buffer must be already allocated and have sufficient size, otherwise GL error is thrown.- Parameters:
offset
- items offset (items to be skipped). Can be zeroitems
- how many items we want to readreader
- reader that reads the data from the buffer
-