View Full Version : Slow shader compilation

12-16-2011, 02:44 AM
Hi All,

How can we speed-up shader compilation?

We need to compile 14 shaders (7 vertex + 7 fragment shaders) and takes some time.

Would string compression help in this case?



carsten neumann
12-16-2011, 07:09 AM
See glGetProgramBinary (http://www.opengl.org/sdk/docs/man4/xhtml/glGetProgramBinary.xml) for a way to cache compiled shaders.
Beyond that I think you'd have to get a job at the vendor that writes your drivers and work on optimizing their shader compiler ;)
What does "takes some time" mean here, are we talking about tens of milliseconds or minutes? Is the compilation the bottleneck or is perhaps your file IO to load the shader source from disk slow?

12-16-2011, 07:27 AM
I will send a resume to ATI.com Carsten :D

By the way we see a small delay in loading the OpenGL viewport, about 1 second.

Yes, the bottleneck it the compilation of the 14 shaders source code.

12-17-2011, 11:22 PM

Is there any risk that the compiled shared will not work with all drivers out there?



Alfonse Reinheart
12-18-2011, 12:05 AM
Yes there is. You have to test the program binary against the current driver.

12-18-2011, 06:25 AM
How could we test all the driver on earth, Alfonse?

To me it looks like 'craving for troubles'...

12-18-2011, 07:20 AM
Look at the old extension. There is example code at the bottom

They use this line to test against all the drivers

glGetProgramiv(progObj, GL_LINK_STATUS, &success);
if (!success)