< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_gpu_buffer library
Description
Low level GPU buffers management module: creation, destruction and update (uniform buffers, shader storage buffer, etc).
Number of functions: 33
- gh_gpu_buffer.atomic_counter_get_value ()
- gh_gpu_buffer.atomic_counter_set_value ()
- gh_gpu_buffer.bind ()
- gh_gpu_buffer.bind_base ()
- gh_gpu_buffer.bind_range ()
- gh_gpu_buffer.create ()
- gh_gpu_buffer.create_from_uniform_block ()
- gh_gpu_buffer.map ()
- gh_gpu_buffer.map_range ()
- gh_gpu_buffer.set_matrix4x4 ()
- gh_gpu_buffer.set_value_1f ()
- gh_gpu_buffer.get_value_1f ()
- gh_gpu_buffer.set_value_1ui ()
- gh_gpu_buffer.set_value_1ui64_bindless_texture ()
- gh_gpu_buffer.set_value_2f ()
- gh_gpu_buffer.get_value_2f ()
- gh_gpu_buffer.set_value_3f ()
- gh_gpu_buffer.get_value_3f ()
- gh_gpu_buffer.set_value_4f ()
- gh_gpu_buffer.get_value_4f ()
- gh_gpu_buffer.sub_data_read_1f ()
- gh_gpu_buffer.sub_data_read_1ui ()
- gh_gpu_buffer.sub_data_read_2f ()
- gh_gpu_buffer.sub_data_read_3f ()
- gh_gpu_buffer.sub_data_read_4f ()
- gh_gpu_buffer.sub_data_write_1f ()
- gh_gpu_buffer.sub_data_write_1ui ()
- gh_gpu_buffer.sub_data_write_2f ()
- gh_gpu_buffer.sub_data_write_3f ()
- gh_gpu_buffer.sub_data_write_4f ()
- gh_gpu_buffer.unbind ()
- gh_gpu_buffer.unmap ()
- gh_gpu_buffer.set_value_4x4f ()
atomic_counter_get_value
Description
Gets the value of an atomic counter.
Syntax
x = gh_gpu_buffer.atomic_counter_get_value(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
- x [INTEGER]: atomic counter value
Code sample
x = gh_gpu_buffer.atomic_counter_get_value(gpubuff_id, 4)
atomic_counter_set_value
Description
Sets the value of an atomic counter.
Syntax
gh_gpu_buffer.atomic_counter_set_value(
gpubuff_id,
offset,
x
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x [INTEGER]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.atomic_counter_set_value(gpubuff_id, 4, x)
bind
Description
Binds a GPU buffer object.
Syntax
gh_gpu_buffer.bind(
gpubuff_id
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind(gpubuff_id)
bind_base
Description
Binds a GPU buffer object on a specific buffer binding point.
Syntax
gh_gpu_buffer.bind_base(
gpubuff_id,
binding_point_index
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- binding_point_index [INTEGER]: index of the binding point
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
bind_range
Description
Binds a part of a GPU buffer object on a specific buffer binding point.
Syntax
gh_gpu_buffer.bind_range(
gpubuff_id,
binding_point_index,
offset,
size
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- binding_point_index [INTEGER]: index of the binding point
- offset [INTEGER]: offset from the start of the buffer in bytes
- size [INTEGER]: size in bytes
Return Values
This function has no return value(s).
Code sample
binding_point_index = 1
gh_gpu_buffer.bind_range(gpubuff_id, binding_point_index, 128, 256)
create
Description
Creates a GPU buffer object.
Syntax
gpubuff_id = gh_gpu_buffer.create(
buff_type,
buff_usage,
buff_size,
buff_states
)
Languages
Parameters
- buff_type [ENUM]: type of the buffer: 'UNIFORM', 'SHADER_STORAGE', 'ATOMIC_COUNTER', etc.
- buff_usage [ENUM]: usage based on OpenGL constants: 'GL_STATIC_DRAW', 'GL_DYNAMIC_READ', etc.
- buff_size [INTEGER]: size of the buffer in bytes
- buff_states [STRING]: reserved. Set it to ''
Return Values
- gpubuff_id [ID]: gpu buffer identifier
Code sample
gpubuff_id = gh_gpu_buffer.create("SHADER_STORAGE", "GL_DYNAMIC_COPY", 256, "")
create_from_uniform_block
Description
Creates an uniform buffer object from a shader uniform block description.
Syntax
gpubuff_id = gh_gpu_buffer.create_from_uniform_block(
buff_usage,
gpuprog_id,
uniform_block_index,
buff_states
)
Languages
Parameters
- buff_usage [ENUM]: usage based on OpenGL constants: 'GL_STATIC_DRAW', 'GL_DYNAMIC_READ', etc.
- gpuprog_id [ID]: gpu program identifier
- uniform_block_index [INTEGER]: index of the uniform block in the shader. Use gh_gpu_program.get_interface_block_index() to get this index.
- buff_states [STRING]: reserved. Set it to ''
Return Values
- gpubuff_id [ID]: gpu buffer identifier
Code sample
uniform_block_index = gh_gpu_program.get_interface_block_index(gpuprog_id, "UNIFORM", "CameraMatrix")
gpubuff_id = gh_gpu_buffer.create_from_uniform_block("GL_DYNAMIC_READ", gpuprog_id, uniform_block_index, "")
map
Description
Maps a GPU buffer.
Syntax
buffer, buff_size = gh_gpu_buffer.map(
gpubuff_id,
access_mode
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- access_mode [ENUM]: access mode based on OpenGL constants: 'GL_READ_WRITE', 'GL_WRITE_ONLY', 'GL_READ_ONLY'
Return Values
- buffer [POINTER]: memory buffer
- buff_size [INTEGER]: buffer size in bytes
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
buffer, buffer_size = gh_gpu_buffer.map(gpubuff_id, "GL_WRITE_ONLY")
... WriteSomething(buffer, buffer_size)
gh_gpu_buffer.unmap(gpubuff_id)
map_range
Description
Maps a range of a GPU buffer.
Syntax
buffer, buff_size = gh_gpu_buffer.map_range(
gpubuff_id,
offset,
size,
access_mode
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- size [INTEGER]: size in bytes
- access_mode [ENUM]: access mode based on OpenGL constants: 'GL_MAP_READ_BIT', 'GL_MAP_WRITE_BIT', 'GL_MAP_INVALIDATE_RANGE_BIT', 'GL_MAP_INVALIDATE_BUFFER_BIT', etc
Return Values
- buffer [POINTER]: memory buffer
- buff_size [INTEGER]: buffer size in bytes
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
buffer, buffer_size = gh_gpu_buffer.map_range(gpubuff_id, 0, 256, "GL_MAP_WRITE_BIT GL_MAP_INVALIDATE_RANGE_BIT")
... WriteSomething(buffer, buffer_size)
gh_gpu_buffer.unmap(gpubuff_id)
set_matrix4x4
Description
Writes a 4x4 matrix value to a GPU buffer. The matrix comes from an object (camera, mesh, etc.).
Syntax
gh_gpu_buffer.set_matrix4x4(
gpubuff_id,
offset,
obj_id,
matrix_type
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- obj_id [ID]: object identifier
- matrix_type [ENUM]: type of the matrix: 'camera_view_projection', 'camera_view', 'camera_inv_view', 'camera_projection', 'camera_inv_projection' 'object_local_tranform', 'object_global_tranform'
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_matrix4x4(gpubuff_id, offset, cam_id, "camera_view camera_projection")
set_value_1f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.set_value_1f(
gpubuff_id,
offset,
x
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_value_1f(gpubuff_id, offset, x)
get_value_1f
Description
Reads a 1D value from a GPU buffer.
Syntax
x = gh_gpu_buffer.get_value_1f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
x = gh_gpu_buffer.set_value_1f(gpubuff_id, offset)
set_value_1ui
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.set_value_1ui(
gpubuff_id,
offset,
x
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x [INTEGER]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_value_1ui(gpubuff_id, 0, x)
set_value_1ui64_bindless_texture
Description
Writes a value to a GPU buffer. For bindless textures only.
Syntax
gh_gpu_buffer.set_value_1ui64_bindless_texture(
gpubuff_id,
offset,
tex_id
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- tex_id [ID]: bindless texture identifier
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_value_1ui64_bindless_texture(gpubuff_id, 0, tex_id)
set_value_2f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.set_value_2f(
gpubuff_id,
offset,
x, y
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x, y [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_value_2f(gpubuff_id, offset, x, y)
get_value_2f
Description
Reads a 2D value from a GPU buffer.
Syntax
x, y = gh_gpu_buffer.get_value_2f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
x, y = gh_gpu_buffer.set_value_2f(gpubuff_id, offset)
set_value_3f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.set_value_3f(
gpubuff_id,
offset,
x, y, z
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x, y, z [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_value_3f(gpubuff_id, offset, x, y, z)
get_value_3f
Description
Reads a 3D value from a GPU buffer.
Syntax
x, y, z = gh_gpu_buffer.get_value_3f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
x, y, z = gh_gpu_buffer.set_value_3f(gpubuff_id, offset)
set_value_4f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.set_value_4f(
gpubuff_id,
offset,
x, y, z, w
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x, y, z, w [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_value_4f(gpubuff_id, offset, x, y, z, w)
get_value_4f
Description
Reads a 4D value from a GPU buffer.
Syntax
x, y, z, w = gh_gpu_buffer.get_value_4f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
x, y, z, w = gh_gpu_buffer.set_value_4f(gpubuff_id, offset)
sub_data_read_1f
Description
Reads a value from a GPU buffer.
Syntax
x = gh_gpu_buffer.sub_data_read_1f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
x = gh_gpu_buffer.sub_data_read_1f(gpubuff_id, 128)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_read_1ui
Description
Reads a value from a GPU buffer.
Syntax
x = gh_gpu_buffer.sub_data_read_1ui(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
x = gh_gpu_buffer.sub_data_read_1ui(gpubuff_id, 4)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_read_2f
Description
Reads a value from a GPU buffer.
Syntax
x, y = gh_gpu_buffer.sub_data_read_2f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
x, y = gh_gpu_buffer.sub_data_read_2f(gpubuff_id, 128)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_read_3f
Description
Reads a value from a GPU buffer.
Syntax
x, y, z = gh_gpu_buffer.sub_data_read_3f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
x, y, z = gh_gpu_buffer.sub_data_read_3f(gpubuff_id, 128)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_read_4f
Description
Reads a value from a GPU buffer.
Syntax
x, y, z, w = gh_gpu_buffer.sub_data_read_4f(
gpubuff_id,
offset
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
Return Values
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
x, y, z, w = gh_gpu_buffer.sub_data_read_4f(gpubuff_id, 128)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_write_1f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.sub_data_write_1f(
gpubuff_id,
offset,
x
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
gh_gpu_buffer.sub_data_write_1f(gpubuff_id, 128, x)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_write_1ui
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.sub_data_write_1ui(
gpubuff_id,
offset,
x
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x [INTEGER]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
gh_gpu_buffer.sub_data_write_1ui(gpubuff_id, 4, x)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_write_2f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.sub_data_write_2f(
gpubuff_id,
offset,
x, y
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x, y [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
gh_gpu_buffer.sub_data_write_2f(gpubuff_id, 128, x, y)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_write_3f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.sub_data_write_3f(
gpubuff_id,
offset,
x, y, z
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x, y, z [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
gh_gpu_buffer.sub_data_write_3f(gpubuff_id, 128, x, y, z)
gh_gpu_buffer.unbind(gpubuff_id)
sub_data_write_4f
Description
Writes a value to a GPU buffer.
Syntax
gh_gpu_buffer.sub_data_write_4f(
gpubuff_id,
offset,
x, y, z, w
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- x, y, z, w [REAL]: value
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
gh_gpu_buffer.sub_data_write_4f(gpubuff_id, 128, x, y, z, w)
gh_gpu_buffer.unbind(gpubuff_id)
unbind
Description
Unbinds a GPU buffer object.
Syntax
gh_gpu_buffer.unbind(
gpubuff_id
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.unbind(gpubuff_id)
unmap
Description
Unmaps a GPU buffer.
Syntax
gh_gpu_buffer.unmap(
gpubuff_id
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.bind_base(gpubuff_id, 0)
gh_gpu_buffer.map(gpubuff_id, "GL_WRITE_ONLY")
... WriteSomething(gpubuff_id)
gh_gpu_buffer.unmap(gpubuff_id)
set_value_4x4f
Description
Writes a value (a 4x4 matrix) to a GPU buffer.
Syntax
gh_gpu_buffer.set_value_4x4f(
gpubuff_id,
offset,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
Languages
Parameters
- gpubuff_id [ID]: gpu buffer identifier
- offset [INTEGER]: offset from the start of the buffer in bytes
- m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 [REAL]: the 16 floats that make the 4x4 matrix
Return Values
This function has no return value(s).
Code sample
gh_gpu_buffer.set_value_4x4f(gpubuff_id, offset, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
| |