Hello!
As far as I understand, one can write compiled and linked binary objects to a file so that they may be cached and loaded at a later time. This can be done both for separate, compiled shader objects and complete, linked program objects. The OpenGL extension for this feature is GL_ARB_get_program_binary. (Please correct me on any and all details here.)
My issue is concerned with querying whether or not my OpenGL context/GPU supports these features. According to the OpenGL specification Version 4.1 (Core) – I am unable to create a context higher than this at the moment because of a bug in the nvidia drivers – on page 53, section 2.11 “Vertex Shaders”, it says:
“A GL implementation must support shader compilation (the boolean value [GL_]SHADER_COMPILER must be [GL_]TRUE). If the integer value of [GL_]NUM_SHADER_BINARY_FORMATS is greater than zero, then shader binary loading is supported.”
Some Googling lead me to believe that the integer value of GL_NUM_PROGRAM_BINARY_FORMATS (note, “PROGRAM” instead of “SHADER”) is the query token to see if program binary loading is supported.
I wrote some code to query these values after context (4.1) creation and after GLEW initialization.
GLboolean shader_compiler;
glGetBooleanv(GL_SHADER_COMPILER, &shader_compiler);
printf("GL_SHADER_COMPILER: %d
", shader_compiler);
if (shader_compiler == GL_TRUE) {
puts("shader compilation supported");
} else if (shader_compiler == GL_FALSE) {
puts("shader compilation not supported");
}
GLint program_formats = 0;
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &program_formats);
printf("GL_NUM_PROGRAM_BINARY_FORMATS: %d
", program_formats);
if (program_formats > 0) {
puts("program binary loading supported");
} else {
puts("program binary loading not supported");
}
GLint shader_formats = 0;
glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &shader_formats);
printf("GL_NUM_SHADER_BINARY_FORMATS: %d
", shader_formats);
if (shader_formats > 0) {
puts("shader binary loading supported");
} else {
puts("shader binary loading not supported");
}
Output for the code above is:
GL_SHADER_COMPILER: 1
shader compilation supported
GL_NUM_PROGRAM_BINARY_FORMATS: 1
program binary loading supported
GL_NUM_SHADER_BINARY_FORMATS: 0
shader binary loading not supported
How come shader binary loading is not supported while program binary loading is? I’ve been Googling this for about 3 days now and I am none the wiser. Is there something I need to do to enable it?
[ul][li] I run Ubuntu 11.10[] The GPU is an Nvidia GeForce GTX 580 with driver version 290.10[] I use GLFW to open a window with a context; installed version is 2.7.2[*] GLEW version is 1.7.0.[/ul][/li]Thank you for your time!