View Full Version : glsl headers for compute shader convenience

06-26-2013, 06:22 PM
I was wondering if GLSL has functionality for header files. This comes in handy for the compute shader where one may use routines over and over again, such as some image processing functions. I have seen some image processing examples in GLSL for the compute shader but they do not make use of header files, which makes me think that the compute shaders practicality is limited to smaller source code computations. So is there a way to have includes in the compute shader?

Well the only way to load a source is through glShaderSource. It is possible to get back a binary. Is it possible to compile routines into binaries and use them at run time in a GL context?

The short answer is probably to use OpenCL with an associated OpenGL interop, but I am just curious about the compute shader.

06-26-2013, 07:15 PM
There is currently no #include in the specs so it left to use to do a pre-processor pass for this. You can use look at this extension ARB_shading_language_include. It is possible to save the binary and use it but it is generally not used because the code is specific for the gpu and so a program using this may not run on another