PDA

View Full Version : Slow shader compilation



devdept
12-16-2011, 03: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?

Thanks,

Alberto

carsten neumann
12-16-2011, 08: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?

devdept
12-16-2011, 08: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.

devdept
12-18-2011, 12:22 AM
carsten,

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

Thanks,

Alberto

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

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

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

V-man
12-18-2011, 08:20 AM
Look at the old extension. There is example code at the bottom
http://www.opengl.org/registry/specs/ARB/get_program_binary.txt

They use this line to test against all the drivers

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