gallivm: consolidate code for float-to-half and float-to-packed conversion.

This replaces the existing float-to-half implementation.
There are definitely a couple of differences - the old implementation
had unspecified(?) rounding behavior, and could at least in theory
construct Inf values out of NaNs. NaNs and Infs should now always be
properly propagated, and rounding behavior is now towards zero
(note this means too large but non-Infinity values get propagated to max
representable value, not Infinity).
The implementation will definitely not match util code, however (which
does nearest rounding, which also means too large values will get
propagated to Infinity).

Also fix a bogus round mask probably leading to rounding bugs...
v2: fix a logic bug in handling infs/nans.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
gallivm: bring back optimized but incorrect float to smallfloat optimizations

Conceptually the same as previously done in float_to_half.
Should cut down number of instructions from 14 to 10 or so, but
will promote some NaNs to Infs, so it's disabled.
It gets a bit tricky though handling all the cases correctly...
Passes basic tests either way (though there are no tests testing special
cases, but some manual tests injecting them seemed promising).

v2: style and comment fixes suggested by Jose

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
glsl: Fix array indexing when constant folding built-in functions.

Mesa constant-folds built-in functions by using a miniature GLSL
interpreter (see
ir_function_signature::constant_expression_evaluate_expression_list()).
This interpreter had a bug in its handling of array indexing, which
caused expressions like "m[i][j]" (where m is a matrix) to be handled
incorrectly.  Specifically, it incorrectly treated j as indexing into
the whole matrix (rather than indexing just into the vector m[i]); as
a result the offset computed for m[i] was lost and m[i][j] was treated
as m[j][0].

Fixes piglit tests inverse-mat[234].{vert,frag}.

NOTE: This is a candidate for the 9.1 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57436
Revert "glsl: Replace constant-index vector array accesses with swizzles"

This reverts commit dbf94d105a48b7aafb2c8cf64d8b4392d87efea1, which
was working around a bug in the handling of array indexing when
constant folding built-in functions.  Now that the constant folding
bug has been fixed, the workaround is no longer needed.
Avoid spurious GCC warnings in STATIC_ASSERT() macro.

GCC 4.8 now warns about typedefs that are local to a scope and not
used anywhere within that scope.  This produces spurious warnings with
the STATIC_ASSERT() macro (which uses a typedef to provoke a compile
error in the event of an assertion failure).

This patch avoids the warning using the GCC __attribute__((unused))
syntax.
i965: Reduce code duplication in handling of depth, stencil, and HiZ.

This patch consolidates duplicate code in the brw_depthbuffer and
gen7_depthbuffer state atoms.  Previously, these state atoms contained
5 chunks of code for emitting the _3DSTATE_DEPTH_BUFFER packet (3 for
Gen4-6 and 2 for Gen7).  Also a lot of logic for determining the
appropriate buffer setup was duplicated between the Gen4-6 and Gen7
functions.

This refactor splits the code into three separate functions:
brw_emit_depthbuffer(), which determines the appropriate buffer setup
in a mostly generation-independent way, brw_emit_depth_stencil_hiz(),
which emits the appropriate state packets for Gen4-6, and
gen7_emit_depth_stencil_hiz(), which emits the appropriate state
packets for Gen7.

Tested using Piglit on Gen5-7 (no regressions).

v2: Re-word some comments.  Fix an assertion that incorrectly
prohibited packed depth/stencil formats on Gen6 (these are allowed
provided that HiZ is disabled).
!UPSTREAM: Hacky fix for Gen5 depthstencil-render-miplevels stencil-only test.  TODO: think through, test thoroughly, and document.
De-virtualize brw_blorp_params class
i965/blorp: Convert brw_blorp_mip_info into a C struct
i965/blorp: Convert brw_blorp_surface_info into a C struct
i965/blorp: Convert brw_blorp_coord_transform_params into a C struct
i965/blorp: Convert brw_blorp_wm_push_constants into a C struct
i965/blorp: Convert more stuff to C
Convert more stuff to C
Convert brw_blorp_params into C
Convert more stuff to C
Convert brw_hiz_op_params to C
Convert brw_blorp_blit_params to C
Convert the rest of brw_blorp.h to C
!UPSTREAM: i965/blorp: Merge into brw_wm_prog.

TODO: disentangle prep work.