I am looking into OpenGL Uniform Buffer Objects and Shader Storage Buffers. I think the question applies to both of them, but let's just focus on UBOs.
Tutorials seem to be saying that "block index" and "binding point index" are different things, and if I have more than one UBO in a shader, I need to specify the binding index
layout(binding = 0) uniform first_buffer {...};
layout(binding = 1) uniform second_buffer {...};
I get the impression that the block index is determined by the linker and can be read from glGetUniformBlockIndex
, but the binding point index has to be hard-coded with arbitrary distinct binding=N
in the layout, and a corresponding glBindBufferBase(GL_UNIFORM_BUFFER, N, ubo_handle)
, which strikes me as fragile and a nuisance.
What is the difference between a block index and a binding point?
Can I omit the binding=N
in the layout? What happens then with glBindBufferBase
?
Is this all the same for SSBOs?