Is there a glCompileShader option?

During debugging of my system, I found out that all the shaders I used were never compiled. All GLSL programs were happily connected and worked like a charm.

I searched the entire code base for glCompileShader calls, but none were found.

Then my question is: Is this the specific behavior of the implementation I'm working with? Is shader compilation performed implicitly when linking a program? It's not obligatory? If so, what are the benefits of this explicitly, except for getting an error log?

I could not find a single case, for example, my document, if I missed something, can you point me to this?

My supplier is NVIDIA (driver 337.88)

EDIT: Also, I am NOT using glCreateShaderProgram() , but just glCreateProgram() to create shader programs.

+7
shader opengl
source share
1 answer

This was mostly allowed in the comments (thanks @Andon, @derhass, etc.), but since this is an interesting question, let me summarize it in the answer and add some more data.

glCompileShader() precompiled shaders, you need to compile your shaders by calling glCompileShader() before linking the program to glLinkProgram() . Based on the collected data, skipping the call to glCompileShader() works fine:

  • NVIDIA GeForce GT 740M under Windows 8.1.
  • NVIDIA for Linux (by @derhass).
  • NVIDIA GeForce GT 620M under Windows 8 (from @cifz)

Failure:

  • Intel HD 4600 under Windows 8.1.
  • Intel Iris for Mac OS 10.9.2.
  • iPad Air for iOS 7.1.
  • Two different Android tablets.

Thus, this behavior seems clearly isolated from NVIDIA. Specifications say compiling shaders before binding is necessary. From 3.3 specifications:

Linking will also fail if one or more shader objects attached to the program are not compiled successfully.

Specifications 4.4 are a little less clear, turning possible error conditions into a list that starts with:

Linking may fail ...

It can usually be assumed that behavior is optional, but I'm not sure if this is the intention here. It seems to me that the specifications were simply reformatted and the intended behavior has not changed. So IMHO, this is a mistake. Not very serious, since all legal use still works, but I don’t think that what NVIDIA does is strictly following the specifications.

In any case, calling glCompileShader() before glLinkProgram() necessary for your code to work on different platforms.

+6
source share

All Articles