OpenGL extension ARB.uniform_buffer_object
This module customises the behaviour of the
OpenGL.raw.GL.ARB.uniform_buffer_object to provide a more
Overview (from the spec)
This extension introduces the concept of a group of GLSL uniforms
known as a "uniform block", and the API mechanisms to store "uniform
blocks" in GL buffer objects.
The extension also defines both a standard cross-platform layout in
memory for uniform block data, as well as mechanisms to allow the GL
to optimize the data layout in an implementation-defined manner.
Prior to this extension, the existing interface for modification of
uniform values allowed modification of large numbers of values using
glUniform* calls, but only for a single uniform name (or a uniform
array) at a time. However, updating uniforms in this manner may not
map well to heterogenous uniform data structures defined for a GL
application and in these cases, the application is forced to either:
A) restructure their uniform data definitions into arrays
B) make an excessive number of calls through the GL interface
to one of the Uniform* variants.
These solutions have their disadvantages. Solution A imposes
considerable development overhead on the application developer.
Solution B may impose considerable run-time overhead on the
application if the number of uniforms modified in a given frame of
rendering is sufficiently large.
This extension provides a better alternative to either (A) or (B) by
allowing buffer object backing for the storage associated with all
uniforms of a given GLSL program.
Storing uniform blocks in buffer objects enables several key use
- sharing of uniform data storage between program objects and
between program stages
- rapid swapping of sets of previously defined uniforms by storing
sets of uniform data on the GL server
- rapid updates of uniform data from both the client and the server
The data storage for a uniform block can be declared to use one of
three layouts in memory: packed, shared, or std140.
- "packed" uniform blocks have an implementation-dependent data
layout for efficiency, and unused uniforms may be eliminated by
the compiler to save space.
- "shared" uniform blocks, the default layout, have an implementation-
dependent data layout for efficiency, but the layout will be uniquely
determined by the structure of the block, allowing data storage to be
shared across programs.
- "std140" uniform blocks have a standard cross-platform cross-vendor
layout (see below). Unused uniforms will not be eliminated.
Any uniforms not declared in a named uniform block are said to
be part of the "default uniform block".
While uniforms in the default uniform block are updated with
glUniform* entry points and can have static initializers, uniforms
in named uniform blocks are not. Instead, uniform block data is updated
using the routines that update buffer objects and can not use static
Rules and Concepts Guiding this Specification:
For reference, a uniform has a "uniform index" (subsequently
referred to as "u_index) and also a "uniform location" to
efficiently identify it in the uniform data store of the
implementation. We subsequently refer to this uniform data store of
the implementation as the "uniform database".
A "uniform block" only has a "uniform block index" used for queries
and connecting the "uniform block" to a buffer object. A "uniform
block" has no "location" because "uniform blocks" are not updated
directly. The buffer object APIs are used instead.
Properties of Uniforms and uniform blocks:
a) A uniform is "active" if it exists in the database and has a valid
b) A "uniform block" is "active" if it exists in the database and
has a valid ub_index.
c) Uniforms and "uniform blocks" can be inactive because they don't
exist in the source, or because they have been removed by dead
d) An inactive uniform has u_index == INVALID_INDEX.
e) An inactive uniform block has ub_index == INVALID_INDEX.
f) A u_index or ub_index of INVALID_INDEX generates the
INVALID_VALUE error if given as a function argument.
g) The default uniform block, which is not assigned any ub_index, uses a
private, internal data storage, and does not have any buffer object
associated with it.
h) An active uniform that is a member of the default uniform block has
location >= 0 and it has offset == stride == -1.
i) An active uniform that is a member of a named uniform block has
location == -1.
j) A uniform location of -1 is silently ignored if given as a function
k) Uniform block declarations may not be nested
The official definition of this extension is available here:
|EXTENSION_NAME = 'GL_ARB_uniform_buffer_object'|
GL_ACTIVE_UNIFORM_BLOCKS = GL_ACTIVE_UNIFORM_BLOCKS
GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH = GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH
GL_INVALID_INDEX = GL_INVALID_INDEX
GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS
GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS = GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS
GL_MAX_COMBINED_UNIFORM_BLOCKS = GL_MAX_COMBINED_UNIFORM_BLOCKS
GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS
GL_MAX_FRAGMENT_UNIFORM_BLOCKS = GL_MAX_FRAGMENT_UNIFORM_BLOCKS
GL_MAX_GEOMETRY_UNIFORM_BLOCKS = GL_MAX_GEOMETRY_UNIFORM_BLOCKS
GL_MAX_UNIFORM_BLOCK_SIZE = GL_MAX_UNIFORM_BLOCK_SIZE
GL_MAX_UNIFORM_BUFFER_BINDINGS = GL_MAX_UNIFORM_BUFFER_BINDINGS
GL_MAX_VERTEX_UNIFORM_BLOCKS = GL_MAX_VERTEX_UNIFORM_BLOCKS
GL_UNIFORM_ARRAY_STRIDE = GL_UNIFORM_ARRAY_STRIDE
GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS = GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS
GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
GL_UNIFORM_BLOCK_BINDING = GL_UNIFORM_BLOCK_BINDING
GL_UNIFORM_BLOCK_DATA_SIZE = GL_UNIFORM_BLOCK_DATA_SIZE
GL_UNIFORM_BLOCK_INDEX = GL_UNIFORM_BLOCK_INDEX
GL_UNIFORM_BLOCK_NAME_LENGTH = GL_UNIFORM_BLOCK_NAME_LENGTH
GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER
GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER = GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER
GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER
GL_UNIFORM_BUFFER = GL_UNIFORM_BUFFER
GL_UNIFORM_BUFFER_BINDING = GL_UNIFORM_BUFFER_BINDING
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT
GL_UNIFORM_BUFFER_SIZE = GL_UNIFORM_BUFFER_SIZE
GL_UNIFORM_BUFFER_START = GL_UNIFORM_BUFFER_START
GL_UNIFORM_IS_ROW_MAJOR = GL_UNIFORM_IS_ROW_MAJOR
GL_UNIFORM_MATRIX_STRIDE = GL_UNIFORM_MATRIX_STRIDE
GL_UNIFORM_NAME_LENGTH = GL_UNIFORM_NAME_LENGTH
GL_UNIFORM_OFFSET = GL_UNIFORM_OFFSET
GL_UNIFORM_SIZE = GL_UNIFORM_SIZE
GL_UNIFORM_TYPE = GL_UNIFORM_TYPE
__file__ = '/home/mcfletch/pylive/OpenGL/GL/ARB/uniform_buffer_object.pyc'
__name__ = 'OpenGL.GL.ARB.uniform_buffer_object'
__package__ = 'OpenGL.GL.ARB'
glGetActiveUniformBlockName = <OpenGL.platform.baseplatform.glGetActiveUniformBlockName object at 0x7433c10>
glGetActiveUniformBlockiv = <OpenGL.platform.baseplatform.glGetActiveUniformBlockiv object at 0x7433b90>
glGetActiveUniformName = <OpenGL.platform.baseplatform.glGetActiveUniformName object at 0x740bc10>
glGetActiveUniformsiv = <OpenGL.platform.baseplatform.glGetActiveUniformsiv object at 0x7409150>
glGetUniformBlockIndex = <OpenGL.platform.baseplatform.glGetUniformBlockIndex object at 0x7433b10>
glGetUniformIndices = <OpenGL.platform.baseplatform.glGetUniformIndices object at 0x7409910>
glUniformBlockBinding = <OpenGL.platform.baseplatform.glUniformBlockBinding object at 0x7433c90>