Binding an atomic counter by name, eg. not using GLSL layout(binding = N)


Is it possible to bind an atomic counter without the need to have a layout declaration in GLSL? In other words, is it possible to bind atomic counters by name? The problem with the layout declaration is that I need to recompile the shader if the index of the binding point changes.

Right now I’m doing the following:

// C++
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, myAtomic);

layout(binding = 0, offset = 0) uniform atomic_uint the_atomic;

Is this possible?