Unbearable GLSL compile time!
category: code [glöplog]
I have a few shaders for different materials / combinations / etc, and the shader compile time is getting annoying.
Do you have any ideas on how to improve this?
Do you have any ideas on how to improve this?
#pragma optimize(off)
(But yeah, you know - stuff might be slower than...)
*then
I've been thinking about that more than a year ago. So here's the question: Do shaders have something like a function wise calling convention? I think it would save a lot of time compiling permutations of the same shaders base code. -.-
thx to the lekktor for the idea. ;)
thx to the lekktor for the idea. ;)
yumeji: I think everything in a shader is inlined. I'm not sure.
yo sorry. I think I'm wrong in that GLthread anyway. DX movin'. :D
yumeji, take a look at dx shader asm ;)
I'm a lil huge outdated... so what? any news? las? fish the whoreship. ;D
Things that can speed up compiles times.
- Dont use include files (Let you framework just cache the include file and inject it as needed)
- If you work in WebGL make sure you have 'Use OpenGL' enabled so he doesn't convert the shaders to DX
- Dont use include files (Let you framework just cache the include file and inject it as needed)
- If you work in WebGL make sure you have 'Use OpenGL' enabled so he doesn't convert the shaders to DX
Generally you should try to trick the compiler to not be able to unroll loops etc. You can also often do a lot to minimize the number of places a function is called.
DX11 has a system of linking shaders but even that leads to the big fat compilation when you actually want to use this linked shader, so it's not helping the problem.
And I doubt dx shader asm is any better - most of the time is spent by creating the shader from the binary blob (actual driver compilation) - not translating it from hlsl to the blob.
Last time I checked the same (very complex) shader in ogl and dx, it compiled much faster in ogl (and produced a much slower shader).
DX11 has a system of linking shaders but even that leads to the big fat compilation when you actually want to use this linked shader, so it's not helping the problem.
And I doubt dx shader asm is any better - most of the time is spent by creating the shader from the binary blob (actual driver compilation) - not translating it from hlsl to the blob.
Last time I checked the same (very complex) shader in ogl and dx, it compiled much faster in ogl (and produced a much slower shader).
3. Make sure you are on nvidia card. Do not ever use ati.
you can give a try at ARB_get_program_binary, compiling only the first time you run your application on a given client machine and saving the binary, but as psycho said, it maybe won't help much..
unc: if you write nvsl instead of real glsl it will usually compile very fast on ati ;)
For hlsl or glsl there isn't much difference.
nystep: the idea for that extension (haven't looked into it at all though) is to be client specific, so it *should* compile to real code for the actual gpu, unlike the dx intermediate code that still has the hard part ahead of it.
For hlsl or glsl there isn't much difference.
nystep: the idea for that extension (haven't looked into it at all though) is to be client specific, so it *should* compile to real code for the actual gpu, unlike the dx intermediate code that still has the hard part ahead of it.
anyone have an example of a shader that takes a while to compile? (i've never actually seen a shader take more than a fraction of a second to compile here.. maybe it means i'm not getting optimised shaders? This is on mac/ati with glsl)
psonice: try having some 10 shaders, each a version for different materials, etc.
Use less shaders.
Because I don't believe you really HAVE to use hundreds of them.
Because I don't believe you really HAVE to use hundreds of them.
Quote:
Use less shaders.
Because I don't believe you really HAVE to use hundreds of them.
It can even be thousands, depending directly on the number of permutations you have. As soon as you have complex materials multiplied by the number of variations of your lighting passes and various options, the numbers skyrocket (exponentially).
Console games usually have thousands shaders per platform (Far Cry 2 had 30,000+ shaders on Xbox 360 afair and from what I know God Of War 3 had more than 40,000)
Yes, of course... but I mean a *single* shader with long compile time.
psonice: [url=http://www.pouet.net/prod.php?which=57248]gl1k Cotton Candy/url] might be your gem :\ it compiles fine in Chrome and Opera but takes forever to compile in Firefox ( at least on Win7 ).