glsl: Stop being clever with pointer arithmetic when fetching types.
glsl: Stop being clever with pointer arithmetic when fetching types.

Currently, vector types are linked together closely: the glsl_type
objects for float, vec2, vec3, and vec4 are all elements of the same
array, in that exact order.  This makes it possible to obtain vector
types via pointer arithmetic on the scalar type's convenience pointer.
For example, float_type + (3 - 1) = vec3.

However, relying on this is extremely fragile.  There's no particular
reason the underlying type objects need to be stored in an array.  They
could be individual class members, possibly with padding between them.
Then the pointer arithmetic would break, and we'd get bad pointers to
non-heap allocated data, causing subtle breakage that can't be detected
by valgrind.  Cue insanity.

Or someone could simply reorder the type variables, causing us to get
the wrong type entirely.  Also cue insanity.

Writing this explicitly is much safer.  With the new helper functions,
it's a bit less code even.

Signed-off-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>
Reviewed-by: Eric Anholt <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@anholt.net>

benaadams/glsl-optimizer,mapbox/glsl-optimizer,djreep81/glsl-optimizer,mapbox/glsl-optimizer,wolf96/glsl-optimizer,metora/MesaGLSLCompiler,bkaradzic/glsl-optimizer,benaadams/glsl-optimizer,zz85/glsl-optimizer,zeux/glsl-optimizer,zeux/glsl-optimizer,metora/MesaGLSLCompiler,jbarczak/glsl-optimizer,bkaradzic/glsl-optimizer,mapbox/glsl-optimizer,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,bkaradzic/glsl-optimizer,mcanthony/glsl-optimizer,tokyovigilante/glsl-optimizer,bkaradzic/glsl-optimizer,dellis1972/glsl-optimizer,mcanthony/glsl-optimizer,zz85/glsl-optimizer,wolf96/glsl-optimizer,jbarczak/glsl-optimizer,jbarczak/glsl-optimizer,djreep81/glsl-optimizer,dellis1972/glsl-optimizer,dellis1972/glsl-optimizer,bkaradzic/glsl-optimizer,zeux/glsl-optimizer,mcanthony/glsl-optimizer,benaadams/glsl-optimizer,zeux/glsl-optimizer,benaadams/glsl-optimizer,jbarczak/glsl-optimizer,wolf96/glsl-optimizer,mcanthony/glsl-optimizer,mapbox/glsl-optimizer,zz85/glsl-optimizer,metora/MesaGLSLCompiler,djreep81/glsl-optimizer,zz85/glsl-optimizer,djreep81/glsl-optimizer,tokyovigilante/glsl-optimizer,tokyovigilante/glsl-optimizer,mcanthony/glsl-optimizer,tokyovigilante/glsl-optimizer,zeux/glsl-optimizer,djreep81/glsl-optimizer,zz85/glsl-optimizer,zz85/glsl-optimizer,wolf96/glsl-optimizer,jbarczak/glsl-optimizer,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,benaadams/glsl-optimizer,benaadams/glsl-optimizer