mesa: Generate FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT earlier

The ARB_framebuffer_object spec lists this case before the
FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER and
FRAMEBUFFER_INCOMPLETE_READ_BUFFER cases.

Fixes two broken cases in piglit's fbo-incomplete test, if
ARB_ES2_compatibility is not advertised. (If it is, this is masked
because the FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER /
FRAMEBUFFER_INCOMPLETE_READ_BUFFER cases are removed by that extension)

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Brian Paul <brianp@vmware.com>
i965/vec4: Add missing doxygen close brace.

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Add and use vec4_instruction::writes_flag().

To be consistent with the fs backend. Also the instruction scheduler
incorrectly considered SEL with a conditional modifier to read the flag
register.

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Rename depends_on_flags() to reads_flag().

To be consistent with the fs backend.

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Print the predicate in dump_instructions().

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Add is_null() method to dst_reg.

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Preparatory clean up of dead_code_eliminate().

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Don't dead code eliminate instructions writing the flag.

A future patch adds support for removing dead writes to the flag
register. This patch simplifies the logic until then.

total instructions in shared programs: 811813 -> 811869 (0.01%)
instructions in affected programs:     3378 -> 3434 (1.66%)

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Track live ranges per-channel, not per vgrf.

Will be squashed with the next patch.

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Let dead code eliminate trim dead channels.

That is, modify

   mad dst, a, b, c

to be

   mad dst.xyz, a, b, c

if dst.w is never read.

total instructions in shared programs: 811869 -> 805582 (-0.77%)
instructions in affected programs:     168287 -> 162000 (-3.74%)

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Factor code out of DCE into a separate function.

Will be reused in the next commit.

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Eliminate writes that are never read.

With an awful O(n^2) algorithm that searches previous instructions for
dead writes.

total instructions in shared programs: 805582 -> 788074 (-2.17%)
instructions in affected programs:     144561 -> 127053 (-12.11%)

Reviewed-by: Eric Anholt <eric@anholt.net>
i965/vec4: Eliminate dead writes to the flag register.

For each write, search previous instructions for unread writes to the
flag register and remove them. Note that this will not eliminate the
last unread write.

total instructions in shared programs: 788074 -> 788004 (-0.01%)
instructions in affected programs:     4930 -> 4860 (-1.42%)

Reviewed-by: Eric Anholt <eric@anholt.net>
i965: Add an env var for forcing window system MSAA.

Sometimes it would be nice to benchmark some app with MSAA versus not, but
it doesn't offer the controls you want.  Just provide a handy knob to
force the issue.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Don't forget to free the old singlesample_mt.

Fixes a memory leak with MSAA winsys buffers since my move of
singlesample_mt to the rb in 4e0924c5de5f3964e4ca81f923d877dbb59fad0a

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Simplify the no-reopening-the-winsys-buffer tests.

The formatting was weird, and the tests were duplicated, and it is
guaranteed that mt->region exists.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Skip reallocating the private MSAA miptree, unless it's resized.

Even if the singlesample_mt got reopened from DRI due to
pageflipping/buffer swapping, our private miptree shouldn't need any
changes.

Improves performance of a little swapbuffers-loving microbenchmark with
MSAA forced on, by 1.2371% +/- 0.624802% (n=102)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
mesa: Stop skipping the FinishRenderTexture calls for winsys FBOs.

Now that BindRenderbufferTexImage() is a thing that drivers can do, winsys
FBOs *can* have NeedsFinishRenderTexture set.

v2: Keep the short-circuit for non-BindRenderbufferTexImage() drivers
    (review by Ken).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965/gen8: Change the winsys MSAA blits from blorp to meta.

This gets us equivalent code paths on BDW and pre-BDW, except for stencil
(where we don't have MSAA stencil resolve code yet)

Improves MSAA-forced citybench by 7.94496% +/- 2.38429% (n=16).  Reduces
DRI2 MSAA glxgears performance by -12.3559% +/- 1.52845% (n=9).

v2: Move the new meta code to brw_meta_updownsample.c, name it
    brw_meta_updownsample(), add a comment about
    intel_rb_storage_first_mt_slice(), and rename that function and move
    the RB generation into it (review ideas by Ken).
v3: Fix 2 src vs dst pasteos in previous change.
v4: Skip this path pre-gen8 for now, until we can analyze the glxgears
    performance delta some more.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Fix compiler warning about signed/unsigned.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>