i965/fs: Recalculate live intervals in calculate_register_pressure().

Otherwise calling dump_instructions() after declaring a new fs_reg would
segfault when calculate_register_pressure()'s loop over reg walked off
the end of the virtual_grf_start[] array that calculate_live_intervals()
would have reallocated for you, if it had known there was a new
register.
i965/fs: Name temporary ralloc contexts something other than mem_ctx.

Or else poor programmers might mistakenly use the temporary mem_ctx,
instead of the fs_visitor's mem_ctx and wonder why their code is
crashing.

Also remove the parenting. These contexts are local to the optimization
passes they're in and are freed at the end.
i965/vec4: Consider sources of non-GRF-dst instructions for dead channels.

Previously we'd ignore the sources of instructions with non-GRF
destinations when calculating calculating the dead channels. This would
lead to us incorrectly removing the first instruction in this sequence:

   mov vgrf11, ...
   cmp.ne.f0 null, vgrf11, 1.0
   mov vgrf11, ...

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76616
i965/fs: Fix off-by-one in saturate propagation.

ip needs to be initialized to start_ip - 1, since the first thing in the
main loop is ip++. Otherwise we would incorrectly propagate the saturate
from the mov to the mad:

   mad     a, b, c, d
   mov.sat x, a
   add     y, z, a

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
i965/fs: Don't propagate saturate modifiers into partial writes.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
i965/fs: Don't propagate saturation modifiers if there are source modifiers.

Which would lead to translating

   mad     vgrf9:F,  vgrf3:F, u0:F, vgrf6:F
   mov.sat vgrf7:F, -vgrf9:F

into

   mad.sat vgrf9:F,  vgrf3:F, u0:F, vgrf6:F
   mov     vgrf7:F, -vgrf9:F

Fixes some lighting effects in Dota2.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76749
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
i965: Mark is_tex() and friends as const.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
i965/fs: Mark appropriate fs_inst members as const.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
i965/fs: Split fs_visitor::register_coalesce() into its own file.

The function has gotten large, and brw_fs.cpp is the largest source file
in the driver.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
i965/fs: Split out is_coalesce_candidate() function.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
i965/fs: Split out can_coalesce_vars() function.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
glsl: Optimize (x + y cmp 0) into (x cmp -y).

Cuts a small handful of instructions in Serious Sam 3:

instructions in affected programs:     4692 -> 4666 (-0.55%)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
i965/vec4: Allow constant propagation into dot product.

total instructions in shared programs: 1667088 -> 1667055 (-0.00%)
instructions in affected programs:     3362 -> 3329 (-0.98%)

Reviewed-by: Eric Anholt <eric@anholt.net>
gallium: add support for LODQ opcodes.

This opcode provide support for GL_ARB_texture_query_lod,

Signed-off-by: Dave Airlie <airlied@redhat.com>
[imirkin: rebase, docs update]
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
st/mesa: add support for ARB_texture_query_lod

Add support for the LODQ texture instruction.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
nv50: enable texture query lod

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
nvc0: enable texture query lod

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
docs: mark ARB_texture_query_lod as done for nv50, nvc0

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
nvc0: add support for texture gather

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
docs: mark ARB_texture_gather as done on nvc0

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>