Bitten by dynamic shader recompile?

I think I have been bitten by the feature of NVidias whereby they can dynamically recompile a shader due to changes in uniform.

I have a few moderately parameterised shaders, and a sometimes a uniform needs to be undated per frame, however I am hitting big cpu loads (50%+) when doing so, which looks like the previously discussed feature of NVidias where they recompile to potimise the shaders.

Now, I really really cannot afford for that to happen, does anyone know of a way to avoid it? unfortunately using vertex attributes instead of uniforms will not work in my application…

I have been trying drivers around 185 and the latest (2xx?) and if anything the new ones seem to respond a little worse than the old ones (I guess a slightly heavier optimiser?)

a #pragma DONT_RECOMPILE would be nice :wink:

Thanks a ton for any input.

What hardware do you have?

About to ask that same thing. If it’s GF7 or earlier, it’s certainly possible. Haven’t seen this GF8+.

NVidias where they recompile to potimise the shaders.

You could modify expressions using the uniforms to pull some data from attributes (of value known to you) to try to prevent these optimizations.

something like:

uniform float value;
float zero = gl_Vertex.w - 1;
if( value + zero > 4 ) ...

Or some more clever stuff.
Yes its silly, but may help.

For more info, see:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.