Are uniform values saved when switching shaders?

Lets say I have 2 shader programs, A & B, and do the following:

  1. Use program A
  2. Set uniforms for program A
  3. Render something
  4. Use program B
  5. Set uniforms for program B
  6. Render something else

If I now want to render something with program A again, do I need to re-set all the uniforms it uses, or will the uniforms be restored automatically? The GL ES 2.0 spec doesn’t mention it at all and the GL 2.0 spec only mentions that uniform values are stored as part of the program state (in section 2.15.5 - Required State).

Yes, uniform values are part of the program state. A uniform of a program will keep its value until you change it.

Great, thanks a lot for that question!