fragend-glsl: avoid re-getting the shader state

This reduces how often we have to get the shader state for a pipeline
while generating the code for each layer of the pipeline. This also
separates looking up the corresponding layer state with a layer index
from the codegen code. This would allow us to avoid redundant index
based lookups if we were to start generating code for layers that aren't
used internally.
gl: consider min glsl version for core profile

We can't assume that drivers have support for glsl 1.2 when we are
requesting to use the core profile for GL 3 drivers. This makes cogl
request the minimum glsl version that we we know must be available for
core profile drivers.

This is required to use Cogl on later versions of OSX.