Scope of glBindBufferBase


Does glBindBufferBase bind the defined UBO to the specified binding point globally for all shaders regardless of the currently bound shader? If so is there a way to only bind it to a specific shader? I’m having an issue where my shaders all have their own ubo data sets but if there is an overlap of layout binding numbers (example two different ubo’s in two different shaders have the same layout binding number) between the shaders then I can’t update them individually because the above call overwrites the mapping.

Uniform block bindings are context state, not program state. If you can’t assign a unique binding point for each UBO (e.g. because there are too many UBOs in total), you’ll need to change the bindings when changing programs.

If the only issue is that the binding points assigned by layout(binding=...) qualifiers conflict, you can use glUniformBlockBinding to reassign them.

This confused me when I first read it. Perhaps it’s more correct to say that they “can conflict”. However, if you’re deliberate about assigning binding indices such that using the same binding index in different shaders indicates UBO sharing across shader/programs (or not), then this is a useful feature, not really a problem.