i965/gs: Add brw->geometry_program.
i965/gs: Add a case to brwBindProgram() for geometry shaders.
i965/gs: Create structs for use by GS program compilation.
i965/gs: Add a case to brwNewProgram() for geometry shaders.
!UPSTREAM: glsl: lower gl_ClipDistanceIn to gl_ClipDistanceInMESA in lower_clip_distance.

This corresponds to the lowering of gl_ClipDistance to gl_ClipDistanceMESA.
It converts the 2D array gl_ClipDistanceIn from EXT/ARB_geometry_shader4 to
a 1D array of vec4s, gl_ClipDistanceInMESA.

v2 (Paul Berry <stereotype441@gmail.com>): Fix indexing order for
gl_ClipDistanceIn lowering.  Properly lower bulk assignment of
gl_ClipDistanceIn[i].

TODO: May need to rework for GLSL 1.50.
!UPSTREAM: glsl/linker: Fail if linking geometry shader with 0 GEOMETRY_VERTICES_OUT.

ARB_geometry_shader4 spec 2.15.2:
"Linking will also fail [...] if the program object contains objects to form a
geometry shader, and the value of GEOMETRY_VERTICES_OUT_ARB is zero."

Reviewed-by: Paul Berry <stereotype441@gmail.com>

TODO: May not be necessary for GLSL 1.50 style geometry shaders.  Make a test to validate.
!UPSTREAM: mesa: fix transform feedback when a geometry shader is active.

TODO: test
!UPSTREAM: Fix up GS handling of gl_ClipDistance/gl_ClipVertex linkage rules.

TODO:
- Test
- Squash
!UPSTREAM: i965: Combine 4 boolean args of brw_urb_WRITE into a flags bitfield.

The arguments to brw_urb_WRITE() were getting pretty unwieldy, and we
have to add more flags to support geometry shaders anyhow.

Also plumb these flags through brw_clip_emit_vue(),
brw_set_urb_message(), and the vec4_instruction class.

TODO:
- Test on Gen4-6
!UPSTREAM: i965: Add an opcode for doing a URB write with an offset from a register (needed for GS).

TODO
- Rename generate_gs_urb_write (and corresponding opcode) to generate_urb_write_override_r0 OSOTS
!UPSTREAM: i965: Add GS_OPCODE_THREAD_END.

TODO:
- Verify that I'm returning the correct value from implied_mrf_writes() for this new opcode.
i965/gs: Add GS_OPCODE_SET_WRITE_OFFSET.
i965/gs: Add GS_OPCODE_SET_VERTEX_COUNT.
i965/gs: Add GS_OPCODE_SET_R0_2.

This opcode will be used by the geometry shader to initialize DWORD 2
of R0, which needs to be 0 in order for scratch reads and writes to
operate correctly.
!UPSTREAM: Primitive ID part 1.
!UPSTREAM: i965/gs: add GS visitors.
!UPSTREAM: Primitive ID part 2.
i965: Make prim_to_hw_prim accessible outside brw_draw.c.

We will need access to this array in order to configure the geometry
shader.
i965/vec4: Make a function for setting up vec4 program key clip info.

This functionality will need to be reused by geometry shaders.
!UPSTREAM: i965/gs: make the state atom for compiling Gen7 geometry shaders.

TODO: maybe disentangle