opengl frequently swapping between two shaders - stack overflow
I have a situation where I have two particular shaders:
The first shader casts shadows from all objects in a scene and renders to a single fullscreen 8 bit shadow texture. The glsl code is very concise.
The second shader performs deferred lighting calculations onto the g-buffer and renders to a single full screen 32bit texture buffer. It uses several full screen textures (32bit position, 16bit normal, 32bit disseminate, 8bit specular, 8bit shadow). The glsl code is also quite verbose.
As you can see, for each light, these two shaders must execute subsequently. A then B, A then B, A then B. This results in a lot of swapping.
Ive read that shader swapping has some high relative overhead, but im unfamiliar with how a GPU would bargain with swapping between only two shaders.
Will the two shader programs be cached effectively enough that this shouldnt be a problem?
Should I mix the two shaders and direct the output using glDrawBuffers()? If I mix them, the 5 textures that are loaded from the previous g-buffer illumination stage would be left stale for the next shadow casting stage, would this cause any performance overhead?