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 short.
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 diffuse, 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.
I've read that shader swapping has some high relative overhead, but im unfamiliar with how a GPU would deal with swapping between only two shaders.
Will the two shader programs be cached effectively enough that this shouldn't be a problem?
Should I combine the two shaders and direct the output using glDrawBuffers()? If I combine 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?