I'm about to implement some functionality which will use uniform buffer objects, and I'm trying to understand the limitations of UBOs before doing so.
For example let's use these GL_MAX_* values and this simple fragment shader:
- GL_MAX_UNIFORM_BUFFER_BINDINGS -> 84
- GL_MAX_UNIFORM_BLOCK_SIZE -> 16384
- GL_MAX_VERTEX_UNIFORM_BLOCKS -> 14
#version 330 core
layout (location = 0) in vec3 aPos;
// UBO
layout (std140, binding = 0) uniform Matrices
{
mat4 projection;
mat4 view;
};
// Individual uniform variables
uniform mat4 model;
uniform vec3 camPos;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
}
Questions:
- Do individual uniform variables each consume one of the
GL_MAX_VERTEX_UNIFORM_BLOCKS, or is there a default uniform block where these variables are stored (I'm guessing the later)? - Is the
GL_MAX_UNIFORM_BLOCK_SIZEthe limit for all defined uniform blocks, or does each defined UBO have a max size of this parameter making in this example the max amount of uniform data allowed to be passed to the shader program 229,376 bytes (spread across multiple ubos)? - If my assumption in question 1 is correct where individually defined uniform variables are contained in a default uniform buffer object:
- A.) does this default buffer also adhere to the 16384 byte limit, meaning that the combined size of all individually defined uniform variables must not exceed 16384 bytes?
- B.) does this default buffer consume a uniform block, leaving max available (before defining any other ubos) 13?
- Do individually defined uniform variables count toward the
GL_MAX_UNIFORM_BUFFER_BINDINGSparameter, leaving 81 available binding locations in this example?