i965/fs: Add support for ir_tg4

Lowers ir_tg4 (from textureGather and textureGatherOffset builtins) to
SHADER_OPCODE_TG4.

The usual post-sampling swizzle workaround can't work for ir_tg4,
so avoid doing that:

* For R/G/B/A swizzles use the hardware channel select (lives in the
   same dword in the header as the texel offset), and then don't do
   anything afterward in the shader.
* For 0/1 swizzles blast the appropriate constant over all the output
   channels in swizzle_result().

V2: Avoid duplicating header enabling block

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965/vs: Add support for ir_tg4

Pretty much the same as the FS case. Channel select goes in the header,
post-sampling swizzle only does the 0/1 cases.

V2: Less mangling.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: Enable ARB_texture_gather on Gen7

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: w/a for gather4 green RG32F

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: Add BRW_SURFACEFORMAT_R32G32_FLOAT_LD, required for IVB gather4 w/a

gather4 GREEN channel against a surface with format R32G32_FLOAT doesn't work
correctly on IVB. w/a from bspec:

   - use R32G32_FLOAT_LD = 0x97 instead, for gather4 only.
   - select BLUE channel to read GREEN

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: make room in the binding table for a full alternate set of surface_states

Worst-case is that *every* texunit uses a format that needs overriding.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: Emit a second set of SURFACE_STATE for gather4 from textures.

This allows us to use a different surface format for gather4, which is
required for R32G32_FLOAT to work on Gen7.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: use gather slots in the binding table for gather4.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: enable one component gather4 on gen6

Gen6 can do gather4, but with the following restrictions and caveats:

- Only one-component formats can be used.
- Only r/g result channels work for INT/UINT surfaces.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965 Gen6: w/a for int/uint gather4

The gather4 message only returns correct data for two of the texels. For
2D samplers (not cubes) we can do a pretty good w/a: issue a second
gather4 with a tweaked offset, and shuffle the other two texels into
place.

For cubes, we will have to do something else, since texel offsets are
not supported with that surface type.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>