Currently I have around 15 render passes in my pipeline. For every pass, I set the correct settings before drawing and reset them afterwards. Those settings include viewport size, depth test on or off, blending function or off, stencil function, stencil operation, and more.
I wonder whether OpenGL is clever enough to ignore API calls which set a state that is already present. Because otherwise I would keep track of the state with a lot of flags and before a render pass only set the state if it is actually necessary.