i965/vec4: Move vec4 data structures and functions to brw_vec4.{cpp,h}.

This patch moves the following things into brw_vec4.{cpp,h}:

- struct brw_vec4_compile
- struct brw_vec4_prog_key
- brw_vec4_prog_data_compare()
- brw_vec4_prog_data_free()

This will allow us to avoid having to include brw_vs.h in
geometry-shader-specific files.
i965/vec4: Allow for dispatch_grf_start_reg to vary.

Both 3DSTATE_VS and 3DSTATE_GS have a dispatch_grf_start_reg control,
which determines the register where the hardware delivers data sourced
from the URB (push constants followed by per-vertex input data).

For vertex shaders, we always set dispatch_grf_start_reg to 1, since
R1 is always the first register available for push constants in vertex
shaders.

For geometry shaders, we'll need the flexibility to set
dispatch_grf_start_reg to different values depending on the behvaiour
of the geometry shader; if it accesses gl_PrimitiveIDIn, we'll need to
set it to 2 to allow the primitive ID to be delivered to the thread in
R1.

This patch eliminates the assumption that dispatch_grf_start_reg is
always 1.  In vec4_visitor, we record the regnum that was passed to
vec4_visitor::setup_uniforms() in prog_data for later use.  In
vec4_generator, we consult this value when converting an abstract
UNIFORM register to a concrete hardware register.  And in the code
that emits 3DSTATE_VS, we set dispatch_grf_start_reg based on the
value recorded in prog_data.

This will allow us to set dispatch_grf_start_reg to the appropriate
value when compiling geometry shaders.  Vertex shaders will continue
to always use a dispatch_grf_start_reg of 1.
i965/vec4: Virtualize setup_payload instead of setup_attributes.

When I initially generaized the vec4_visitor class in preparation for
geometry shaders, I assumed that the setup_attributes() function would
need to be different between vertex and geometry shaders, but its
caller, setup_payload(), could be shared.  So I made
setup_attributes() a virtual function.

It turns out this isn't true; setup_payload() needs to be different
too, since the geometry shader payload sometimes includes an extra
register (primitive ID) that has to come before uniforms.

So setup_payload() needs to be the virtual function instead of
setup_attributes().
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: 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
i965/gs: Add GS_OPCODE_URB_WRITE.

This opcode will be used by geometry shaders to write output vertex
data to the URB.

It differs from VS_OPCODE_URB_WRITE in that it doesn't do an implied
move from R0 to the MRF holding the message header.  This will allow
the geometry shader to direct the output data to the appropriate
vertex in the output URB entry.
i965/gs: Add GS_OPCODE_THREAD_END.

This opcode will be used at the end of a geometry shader thread.  This
is different from what we do in vertex shaders because vertex shaders
always end by writing vertex data to the URB.  Geometry shaders, on
the other hand, write vertex data to the URB during normal execution,
so at the end of the thread, they simply have to output a count of how
many vertices were generated.

As with GS_OPCODE_URB_WRITE, this opcode doesn't do an implied move
from R0 to the MRF holding the message header.  This will allow the
vertex counts to be stored in the message header.
i965/gs: Add GS_OPCODE_SET_WRITE_OFFSET.

This opcode will be used by geometry shaders to store the appropriate
write offset in the message header when performing URB writes of
output vertex data.
i965/gs: Add GS_OPCODE_SET_VERTEX_COUNT.

This opcode will be used by geometry shaders to store the final vertex
counts in the message header when preparing the message that ends the
geometry shader thread.
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: i965/gs: add GS visitors.
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
!UPSTREAM: i965/gs: Generalize some error messages for GS.

TODO: find more places to generalize.
TODO: Don't use "VS/GS" terminology.  Use "vec4" terminology, since that will endure longer.
i965/gs(gen7): Allocate URB space for use by geometry shader.
!UPSTREAM: i965/gs(gen7): Allocate push constant space.