glsl/linker: Defer recording transform feedback locations.

This patch subdivides the loop that assigns varying locations into two
phases: one phase to match up varyings between shader stages (and
assign them varying locations), and a second phase to record the
varying assignments for use by transform feedback.

This paves the way for varying packing, which will require us to
further subdivide the first phase.

In addition, it lets us avoid a clumsy O(n^2) algorithm, since we can
now record the locations of all transform feedback varyings in a
single pass through the tfeedback_decls array, rather than have to
iterate through the array after assigning each varying.
glsl/linker: Subdivide the first phase of varying assignment.

This patch further subdivides the loop that assigns varying locations
into two phases: one phase to match up the varyings between shader
stages, and one phase to assign them varying locations.

In between the two phases the matched varyings are stored in a new
data structure called varying_matches.  This will free us to be able
to assign varying locations in any order, which will pave the way for
packing varyings.
glsl/linker: Sort varyings by packing class, then vector size.

This patch paves the way for varying packing by adding a sorting step
before varying assignment, which sorts the varyings into an order that
increases the likelihood of being able to find an efficient packing.

First, varyings are sorted into "packing classes" by considering
attributes that can't be mixed during varying packing--at the moment
this includes base type (float/int/uint/bool) and interpolation mode
(smooth/noperspective/flat/centroid), though later we will hopefully
be able to relax some of these restrictions.  The number of packing
classes places an upper limit on the amount of space that must be
wasted by varying packing, since in theory a shader might nave 4n+1
components worth of varyings in each of m categories, resulting in 3m
components worth of wasted space.

Then, within each packing class, varyings are sorted by vector size,
with vec4's coming first, then vec2's, then scalars, and then finally
vec3's.  The motivation for this order is that it allows all
power-of-two sized varyings to be located at multiples of their
natural alignment (vec4's located on vec4 boundaries, vec2's located
on vec2 boundaries) without wasting space.  Once the vec4's, vec2's,
and scalars have been placed, the vec3's may be either be aligned to
vec4 boundaries (resulting in a wost-case 33% waste of space) or
aligned to scalar boundaries (resulting in some performance loss).

Note that the varyings aren't actually packed yet, merely placed in an
order that will facilitate packing to be introduced by a later patch.
glsl: Create a field to store fractional varying locations.

Currently, the location of each varying is recorded in ir_variable as
a multiple of the size of a vec4.  In order to pack varyings, we need
to be able to record, e.g. that a vec2 is stored in the second half of
a varying slot rather than the first half.

This patch introduces a field ir_variable::location_frac, which
represents the offset within a vec4 where a varying's value is stored.
Varyings that are not subject to packing will always have a
location_frac value of zero.
glsl/linker: Cache output ir_variable in tfeedback_decl structure.

This patch modifies the linker code for handling transform feedback so
that the output variable (the one in the vertex shader) is looked up
only once, rather than once before it is assigned and again
afterwards.

This paves the way for varying packing, since the process of packing
varyings will sometimes cause the ir_variables representing them to be
"demoted" to ordinary global variables.  We need to ensure that we
don't try to look up the varyings after they are demoted, since we
won't find them.
glsl/linker: Account for packing when storing varying locations.

This patch further paves the way for varying packing by updating the
code that stores varying locations in ir_variable data structures.
Since no back-ends support varying packing natively yet, when we
encounter a set of variables that have been packed, we do the packing
in GLSL IR, by synthesizing a new vec4 to contain the packed values,
and demoting the old (unpacked) varyings to ordinary global variables.
For instance, the following fragment shader:

varying float a;
varying float b;
varying float c;
varying float d;
main()
{
  ...
}

would get rewritten as follows:

varying vec4 packed0;
float a = packed0.x;
float b = packed0.y;
float c = packed0.z;
float d = packed0.w;
main()
{
  ...
}
glsl/linker: Handle fractional locations for transform feedback varyings.

This patch modifies the linking of transform feedback varyings to
account for the fractional varying locations that occur when varyings
are packed.
glsl/linker: Pack varying scalars.

This patch implements varying packing for the simplest case, scalars
(floats, ints, uints, and bools).
Pack vec2's of various kinds
Make an array of new varyings
Add lower_packed_varyings
Use lower_packed_varyings
Allow double-parking
Get rid of no-longer-needed is_packed
Everything can be packed now
Get rid of silly assert
Fix incorrect computation of packing class
Bug fix to lowering pass: skip vars with location=-1
Don't lower stuff that doesn't need lowering
Don't try to pack fixed functionality stuff