Skip to content

buffer

FreeBodyEngine.graphics.gl44.buffer #

SSBOBuffer(data) #

Bases: Buffer

A real GL_SHADER_STORAGE_BUFFER - what backs a buffer block under GL44Generator's real SSBO codegen (see gl44/generator.py), unlike GL33's GL_TEXTURE_BUFFER-based emulation (gl33/buffer.py's TextureBuffer, read-only from GLSL). Readable and writable from a compute shader: compute.buffer_write is a real capability of this backend.

Holds exactly one buffer block's worth of data - if that block declares several fields, all of them are packed into this one buffer, in declaration order, matching std430 layout rules (see GL44Generator.generate_buffer_block()). For the common case of a block with a single field (as both shipped kernels use), that's simply the field's own flat array.

Creates the backing SSBO and uploads data via set_data().

data = None instance-attribute #

ssbo = glGenBuffers(1) instance-attribute #

bind(binding) #

Binds this SSBO to shader storage binding point binding - remembered so unbind() can release the same point later.

destroy() #

Deletes this SSBO's underlying GL buffer.

get_data() #

Returns the data last passed to set_data() - NOT the buffer's live GPU contents if a compute dispatch has written into it since; use read_back() for that.

get_max_size() staticmethod #

Returns the GPU's max shader storage block size in bytes (GL_MAX_SHADER_STORAGE_BLOCK_SIZE).

read_back() #

Reads the buffer's current GPU-side contents (which may have been modified by a compute dispatch writing directly into it - the whole point of a writable SSBO) rather than just returning the last value passed to set_data().

set_data(data) #

Uploads data into the SSBO, replacing its contents. bool arrays are converted to int32 first - GLSL has no packed bool array layout a numpy bool8 upload matches.

unbind() #

Unbinds this SSBO from whatever binding point bind() last used.

UBOBuffer(data) #

Bases: Buffer

Identical to graphics/gl33/buffer.py's UBOBuffer - uniform buffer objects haven't changed at all between GL 3.3 and 4.4.

See UBOBuffer.init (graphics/gl33/buffer.py) - allocates a GL_UNIFORM_BUFFER sized for data and uploads it immediately.

buffer_size = data.nbytes instance-attribute #

data = data instance-attribute #

ubo = glGenBuffers(1) instance-attribute #

bind(point) #

Binds this UBO to uniform binding point point - remembered so unbind() can release the same point later.

destroy() #

Deletes this UBO's underlying GL buffer.

get_data() #

Returns the data last passed to set_data() (or the constructor) - NOT updated by update() below, which writes to the GPU buffer directly without touching this bookkeeping.

get_max_size() staticmethod #

Returns the GPU's max uniform block size in bytes (GL_MAX_UNIFORM_BLOCK_SIZE).

set_data(new_data) #

Replaces this UBO's contents with new_data, reallocating the GPU buffer first if its byte size changed.

unbind() #

Unbinds this UBO from whatever binding point bind() last used.

update(data, offset=0) #

Uploads data into this UBO starting at byte offset, without updating self.data/self.buffer_size the way set_data() does.