PDA

View Full Version : default-block uniform variables



Xzander
06-14-2017, 08:48 AM
Hi,
The GLSL 4.5 Specification states, in section 4.4.3, that "The location identifier can be used with default-block uniform variables and subroutine uniforms". What is a default-block? This isn't mentioned anywhere else, except in that section. I'm wondering how to interpret that.
Thanks

GClements
06-15-2017, 02:34 AM
The GLSL 4.5 Specification states, in section 4.4.3, that "The location identifier can be used with default-block uniform variables and subroutine uniforms". What is a default-block? This isn't mentioned anywhere else, except in that section. I'm wondering how to interpret that.

There are two types of uniform block: the default uniform block and named uniform blocks.

The default uniform block contains uniform variables which are declared at the top-level of a shader, not part of any named uniform block. Variables in the default uniform block have their values set with glUniform() and retrieved with glGetUniform().

A named uniform block is declared in a shader program using the "uniform" keyword followed by a block name followed by the block's members within curly brackets (see 4.3.9 of the GLSL 4.5 specification). Each named uniform block has an associated indexed binding point. Variables in named uniform blocks correspond to regions of the buffer bound to the corresponding binding point using e.g. glBindBufferBase() with a target of GL_UNIFORM_BUFFER.

Named uniform blocks are similar to shader storage blocks (which hold buffer variables), except that shader storage blocks support both reading and and writing (from within the shader), while uniform blocks are read-only.

Xzander
06-15-2017, 06:25 AM
It could not be more clear, thanks a lot for your time!