I'm curious about the *BlockBinding
argument used in several of OpenGLs buffer object related functions.
For example the uniformBlockBinding
parameter in glUniformBlockBinding
, storageBlockBinding​
in glShaderStorageBlockBinding
, and the corresponding index
parameter in glBindBufferRange
and glBindBufferBase
.
I know that calls to glUniformBlockBinding
and glShaderStorageBlockBinding
aren't necessary if binding points are set in the shaders using layout qualifiers such as:
layout (binding = 0) blockName {...}
and from testing around on my machine I've noticed three things:
1) setting binding points with glUniformBlockBinding
and glShaderStorageBlockBinding
override binding points set in the shader using layout qualifiers.
2) block indices returned from glGetUniformBlockIndex
and glGetProgramResourceIndex
are ordered 0 to n for each block of the same type. For example if the shader contains 3 uniform blocks and 2 buffer blocks the indices returned would be [0,1,2] and [0,1] respectively.
3) binding points, set either way, do not conflict across types. For example, setting a uniform block to binding = 0 and a buffer block to binding = 0 is completely safe.
With these assumptions in mind (please correct me if any aren't necessarily true and are simply coincidence), are there any reasons why I shouldn't just have my code automatically set the *BlockBinding
argument to the corresponding block index and save myself the trouble of ever specifying them manually via gl*BlockBinding
or with layout qualifiers.