i965/vp: Keep track of the location of the first PROGRAM_STATE_VAR.

Previously, when compiling ARB vertex shader programs (and fixed
function vertex programs), we assumed that the first PROGRAM_STATE_VAR
was associated with the first element of the brw_vec4_prog_data::param
array.  However, in the patch that follows, we will need to allocate
space for clip plane uniforms before PROGRAM_STATE_VAR uniforms, so
that will no longer be true.

To prevent regressions, this patch records the location of the first
PROGRAM_STATE_VAR uniform, and uses that as an offset when processing
any ARB vertex program instruction that refers to a state var.
i965/gs: Assign clip plane uniform registers before emitting code.

The uniform registers for clip planes need to be assigned before we
try to emit the dot products that convert gl_ClipVertex into
gl_ClipDistance.

In vertex shaders the dot products are emitted by the call
emit_thread_end(), so it is safe to wait until just before that call
to set up the uniform registers for clip planes.  But in geometry
shaders, the dot products are emitted as we're traversing the IR
(since they happen during the shader's call to EmitVertex()).  So we
need to make sure the uniform registers are set up before then.
!UPSTREAM: turn on GS

TODO:
- Commit message
!UPSTREAM: write out cut bits

Stuff that needs fixing:
- Not yet configuring 3DSTATE_GS to indicate that cut bits are present
- Not handling >31 output vertices correctly
- Probably should pack vertex_count and cut_bits into a single register
- Code should be conditioned on whether the shader uses EndPrimitive()
- At end of thread, shouldn't do the write if vertex_count is a multiple of 32
- At end of thread, should write to the appropriate DWORD
- At EmitVertex time, should write cut bits if vertex_counter%32 == 31
!UPSTREAM: vbo: Update vbo_count_tessellated_primitives for new primitive types.

TODO: test.
!UPSTREAM: i965: Add new primitive types.

TODO: test.
!UPSTREAM: Debug optimization passes
glsl: Include EmitVertex() and EndPrimitive() prototypes for GLSL 1.50 GS.

They'd been added to ARB_gs4, but they're used the same way in 1.50.
glsl: !UPSTREAM: Spam in builtin 1.30 variables for 1.50 GSes.

They're supposed to be moved into interface blocks, but I haven't figured
out how to wire that up yet.  At least I can compile geometry-basic now.
glsl: Make sure that we don't put too many bitfields in ast_type_qualifier.

We do some tests of qualifiersusing a union containing an int and the
struct full of bitfields, so make sure the bitfields don't spill outside
the int.
glsl: Parse the GLSL 1.50 GS layout qualifiers.

Limited semantic checking (compatibility between declarations, checking
that they're in the right shader target, etc.) is done.

v2: Remove stray debug printfs.
glsl: Export the compiler's GS layout qualifiers to the gl_shader.

Next step is to validate them at link time.
glsl: Cross-validate GS layout qualifiers while intrastage linking.

This gets piglit's geometry-basic test running.

TODO: Still need to validate that the GS layout qualifiers don't get used
in places they shouldn't (like an interface block, or a particular shader
input or output)
i965/gs: Support UBOs by generating surface state and binding tables.

All but two of the piglit GLSL 1.50/uniform_buffer tests work, and
maxuniformblocksize and referenced-by-shader work.
!UPSTREAM: Expose GLSL 1.50 and GL 3.2 core contexts.

This lets me run tests normally, since globally doing GL version override
can break tests that require a compatibility context.
!UPSTREAM: Fix GS sampling

TODO:

- Seems like these functions ought to be rewritten to loop over
  program types.

- Handling of null gs seems clumsy.

- Can the same sampler be used in multiple shader stages (e.g. both VS
  and FS)?  If not, then it seems like we're going to run out of
  samplers in our bitfield.  If so, then is it guaranteed that
  fs->SamplerUnits[s] == gs->SamplerUnits[s]?  If so this needs an
  explanatory comment.  If not, this code seems broken.

- Decide what to do about code duplication.  Either I should de-dup
  the code or I suppose I should only update the gen7 code.

- Move to appropriate place in the series.
!UPSTREAM: Add EXT_texture_array support for geometry shaders

TODO:

- Move into appropriate place in series

- Would it be better (or even feasible?) to convert the .vert to a
  .glsl and eliminate the redundant functions from the .frag?  Or
  maybe we should have a better mechanism for excluding/including Lod
  versions of texturing functions.
!UPSTREAM: Fix brwBindProgram
!UPSTREAM: Update brwNewProgram for geometry shaders
!UPSTREAM: Fix color clamping for VS when GS in use

TODO:
- Move to appropriate part of patch series.