i965/vec4: Fix broken IR annotation in debug output.

Commit 70953b5 (i965: Initialize all member variables of
vec4_instruction on construction) inadvertently added a line to the
vec4_instruction constructor setting this->ir to NULL, wiping out the
previously set value.  As a result, ever since then, the output of
INTEL_DEBUG=vs and INTEL_DEBUG=gs has been missing IR annotations.

Cc: "10.0" <mesa-stable@lists.freedesktop.org>

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/gen7: Prefer vertical alignment of 4 when possible.

Gen6+ allows for color buffers to use a vertical alignment of either 4
or 2.  Previously we defaulted to 2.  This may have caused problems on
Gen7 because Y-tiled render targets are not allowed to use a vertical
alignment of 2.

This patch changes the vertical alignment to 4 on Gen7, except for the
few formats where a vertical alignment of 2 is required.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965/gen7: Disallow Y tiling of renderable surfaces with valign of 2.

Gen7 does not allow render targets to have a vertical alignment of 2.
So, when creating a surface, if its format is renderable, and its
vertical alignment is 2, force it to use X tiling.

Reviewed-by: Eric Anholt <eric@anholt.net>
gallivm: Fix mask calculation for emit_kill_if.

The exec_mask must be taken in consideration, just like emit_kill above.

The tgsi_exec module has the same bug and should be fixed in a future
change.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
st/mesa: fix GL_FEEDBACK mode inverted Y coordinate bug

We need to check the drawbuffer's orientation before inverting Y
coordinates.  Fixes piglit feedback tests when running with the
-fbo option.

Cc: "9.2" "10.0" <mesa-stable@lists.freedesktop.org>

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
u_gen_mipmap: Use untampered cubemap texture coords when generating mipmaps.

It's not necessary to scale down cubemap texture coords when generating
mipmaps: we are doing a 2x minification therefore it's guaranteed that
the texture coords will always be at least 1 texel away of the edges.

Scaling down can actually be harmful, as it may cause artefacts when
generating mipmaps with nearest filtering.  Sample points will lie
exactly in the middle each 2x2 texels, so the scaling factor was causing
different texels to be take on each quadrant of the cube face.  This is
apparent with a 1x1 checkerboard pattern in the base mipmap level:
instead of next mipmap level receiving a constant color throughout the
face, it will have different colors for each quadrant of the face.

The behaviour for blits is left untouched for now, but the cubemap
texture coord scaling hack should be reconsidered eventually.

Reviewed-by: Brian Paul <brianp@vmware.com>
i965/fs: Use source's original type in register_coalesce().

Previously, register_coalesce() would modify

   mov   vgrf1:f  vgrf2:f
   cmp   null     vgrf3:d  vgrf1:d

to be

   cmp   null     vgrf3:d  vgrf2:f

and incorrectly use vgrf2's type in the instruction that the mov was
coalesced into.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Fix disassembled names of BFI1 and BFI2 instructions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965/fs: Emit compressed 3-source instructions on Haswell.

For commit 4df56177 Paul discovered that the hardware restriction that
Align16 instructions cannot be compressed was lifted on Haswell. This
has prevented us from emitting compressed three-source instructions.

For added confirmation, the bspec lists a work around called
WaBreakSimd16TernaryInstructionsIntoSimd8 that hasn't been applicable
since very early Haswell silicon.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965/fs: Don't emit SIMD16 BFI instructions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965/vec4: Add invalidate_live_intervals method.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Make invalidate_live_intervals() a virtual method of backend_visitor.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Add a pass to remove dead control flow.

Removes IF/ENDIF and IF/ELSE/ENDIF with no intervening instructions.

total instructions in shared programs: 1360393 -> 1360387 (-0.00%)
instructions in affected programs:     157 -> 151 (-3.82%)

(no change in vertex shaders)

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Link -ldl after libmesa.la

DLOPEN_LIBS is part of DRI_LIB_DEPS.

Cc: "10.0" <mesa-stable@lists.freedesktop.org>"
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71512
Reviewed-by: Eric Anholt <eric@anholt.net>
i965/test: Use unreachable() to silence warning.
mesa: Fix setup of LocalParams array.

i965 passed piglit, but swrast and gallium both segfaulted without this.
i965 happened to work because it never ran _mesa_load_state_parameters()
on the new program before the test called glProgramLocalParameter(), which
was allocating a LocalParams array for the fallback path.

v2: Since v1 threw away old localparams data, leaked old LocalParams
    memory, only fixed fragment programs, and I was dubious of my previous
    invariants already (nothing but program_parse.y will generate
    LocalParams, and only that one path of program_parse.y will), just
    late-allocate localparams at the other point of dereferencing them.
    This adds overhead to _mesa_load_state_parameter, which is
    uncomfortable, but I'm pretty sure that giant switch statement is
    super slow already.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71734
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
mesa/swrast: fix inverted front buffer rendering with old-school swrast

I've no idea when this broke, but we have some people who wanted it fixed,
so here's my attempt.

reproducer, run readpix with swrast hit f, or run trival tri -sb things are
upside down, after this patch they aren't.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62142
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66213

Cc: <mesa-stable@lists.freedesktop.org>"
Signed-off-by: Dave Airlie <airlied@redhat.com>
glx: don't fail out when no configs if we have visuals

GLX 1.2 servers with no SGIX_fbconfigs exist (some citrix thing),
and we fail glxinfo completely in those cases.

CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
gallivm: Ignore unknown file type in non-debug builds.

Fixes "Uninitialized pointer read" defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
glsl: Use more portable bash invocation construct.

Fixes 'make check' on distros where bash is not at /bin/bash.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Ian Romanick <ian.d.romanick@intel.com>