I'm really looking forward for a way to know inside a shader at compile time which shader stage is compiled.
For example, I'm usually writing all my pipeline in an unique file like that:
Code :#version 430 core // common uniforms, functions, struct, ... uniform ...; uniform ...; // .. #ifdef VERTEX_SHADER // code for VERTEX_SHADER in vec3 attrib0; ... void main() { } #endif #ifdef FRAGMENT_SHADER // code for FRAGMENT_SHADER ... #endif
A lot of people are doing this stuff, it helps to reduce code duplication of functions/uniforms/... But to get this to work, you need to insert a #define XXX_SHADER at compile time + a #LINE to keep correct debugging information, and because this is not standardized, everybody are using different constants name, hence it is not easy to create tools on top of it.
So why not defining constants such as __VERTEX__, __FRAGMENT__, __COMPUTE, __EVALUATION__, __CONTROLE__ and __GEOMETRY__ when a different shader stage is compiled?