Many articles describe the use of atomic counters by specifying a fixed anchor point:
layout(binding = 0, offset = 0) uniform atomic_uint myAtomicCounter;
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, myBufferHandle);
Here, the hard coding binding = 0point is indicated both in the shader code and in the application code. I think these articles do it this way because
Atomic meters are not assigned a place and may not be with the help of commands Uniform*. The bindings, offsets, and steps belonging to the atomic counters of the program object are invalid, and new ones are assigned after each successful re-reference. [shader_atomic_counters]
The above is fine until you want a more modular shader code. For example, I have two files with shader inclusion, each of which needs an atom counter, which I wrote as a plug-in code that does not know about the other. Clearly, I donβt want to specify hard-coded anchor points, and I would like the application to process it automatically. I don't care what anchor points they use, they just don't match.
The vertex shader attributes are similar. I can force the binding location to be bound at runtime ( glBindAttribLocation) before the shader binding, or alternatively OpenGL select them for me and then request the result ( glGetAttribLocation). I can also search all attributes ( glGetActiveAttrib).
, , ?
, , :
- OpenGL . , OpenGL . , , ?
- , . ,
glBindAttribLocation . ? - , , ,
#define. . .