I brought this up in a recent shading language forum thread, so I thought I’d toss it in here for the record.
The idea is simply to add some sort of syntactic sugar for specifying user defined semantics/attributes within GLSL. The motivation is to provide the user a way of directly communicating variable semantics to the application.
Yes, this can be achieved indirectly, by parsing out embedded comments and such, but this is comparatively inconvenient and considerably less aesthetically pleasing than a structured part of the language would be. I’m also aware that this functionality could be and is layered in other APIs, such as Colada. But my contention is that a language element like this belongs in the language itself, not in some other, non-OpenGL layer.
As a simple example:
[Texture="Clouds.tga", MinFilter="NEAREST", ...]
sampler2D mySampler;
[Type="TimeDelta", Rate="2"]
float timeDelta;
[UI="Slider", Range="0,100"]
float brightness;
The syntax is actually borrowed from C# (without the attribute class name).
Perhaps something more along the lines of a FX type annotation:
sampler2D mySampler
<
Texture="Clouds.tga",
MinFilter="NEAREST",
...
>;
Whatever, it’s simply an optional list of (identifier, string) pairs, and the driver needn’t (necessarily) concern itself with the contents at all. One could store a list of these pairs, and expose a simple API to access a particular item belonging to a particular uniform or attribute.
glGetAttribureAnnotation(int prog, int attr, char* name, int maxLen, char* value);
glGetUniformAnnotation(int prog, int uniform, char* name, int maxLen, char* value);