Is there some flag I can pass to glPushAttrib() that will let me push the shader I set with glUseProgram()? Or is this something that must always be changed manually?
I’m fairly sure this can’t be done - I know I’ve tested glPushAttrib(GL.GL_ALL_ATTRIB_BITS) , and it doesn’t preserve the shader program state. There may be some other function I’m not aware of that pushes shader states, though.
I’m fairly sure the GPU caches the shader in vRAM, not in RAM, so switching between shaders should be rather fast (it appears to be faster than texture-switches)
You can always push/pop shaders in your own code though.
It can cache them in video memory all it wants, but when you switch shaders it’s got to do a full flush of the pipeline as well as setting the new state. In terms of cost, shader switching is about as expensive as it gets.
Hm, I really read in an nVidia document somewhere that their switching-cost was significantly reduced somehow.
I’ll do some benchmarks to find out the real bottleneck.