Detect GPU Vendor from inside GLSL code

Is there a prescribed and/or tested way to detect if your GLSL is being compiled on a specific vendors system? From inside the GLSL code. (I only need a solution for Desktop OpenGL drivers)

In this case there is some GLSL syntax that is not liked by some vendors and I want to conditionally disable it. I know I can add code to the CPU host code, but a GLSL only solution would be better, as some of this code is exported to calling code.
I will try to add optional vendor specific GLSL extensions and then detect then using "#if"s. But if someone can save be some RnD time, please.

Thanks

Not sure if it’s still supported, but for NVIDIA vs. other, might try something like this:

#ifdef __GLSL_CG_DATA_TYPES
  // ... NVIDIA ...
#else
  // ... other ...
#endif

REF:

1 Like