Reputation: 366
According to khronos.org,
GL_MAX_UNIFORM_BLOCK_SIZE
refers to the maximum size in basic machine units of a uniform block. The value must be at least 16384.
I have a fragment shader, where I declared a uniform interface block and attached a uniform buffer object to it.
#version 460 core
layout(std140, binding=2) uniform primitives{
vec3 foo[3430];
};
...
If I query the size of GL_MAX_UNIFORM_BLOCK_SIZE
with:
GLuint info;
glGetUniformiv(shaderProgram.getShaderProgram_id(), GL_MAX_UNIFORM_BLOCK_SIZE, reinterpret_cast<GLint *>(&info));
cout << "GL_MAX_UNIFORM_BLOCK_SIZE: " << info << endl;
I get: GL_MAX_UNIFORM_BLOCK_SIZE: 22098. It is ok, but for example: when I changes the size of the array to 3000 (instead of 3430), I get GL_MAX_UNIFORM_BLOCK_SIZE: 21956
As far as I know, GL_MAX_UNIFORM_BLOCK_SIZE
should be a constant depending on my GPU. Then why does it change, when I modify the size of the array?
Upvotes: 2
Views: 2576
Reputation: 474396
GL_MAX_UNIFORM_BLOCK_SIZE
is properly queried with glGetIntegerv
. It is a constant defined by the implementation which tells you the implementation-defined maximum. glGetUniform
returns the value of a uniform in the given program. You probably got an OpenGL error of some kind, since GL_MAX_UNIFORM_BLOCK_SIZE
is not a valid uniform location, and therefore your integer was never written to. So you're just reading uninitialized data.
Upvotes: 3