i965 gen6+: Make intel_batchbuffer_emit_mi_flush() actually flush.
i965 gen6+: Make intel_batchbuffer_emit_mi_flush() actually flush.

Previous to this patch, the function intel_batchbuffer_emit_mi_flush()
was a bit of a misnomer.  On Gen4+, when not using the blit engine, it
didn't actually flush the pipeline--it simply generated a PIPE_CONTROL
command with the necessary bits set to flush GPU caches.  This was
usually sufficient, since in most situations where
intel_batchbuffer_emit_mi_flush() was called, all we really care about
was ensuring cache coherency.

However, with the advent of OpenGL 3.0, there are two cases in which
data output by one stage of the pipeline might be consumed, in a later
draw operation, by an earlier stage of the pipeline:

(a) When using textures in the vertex shader.

(b) When using drawing with a vertex buffer that was previously
    generated using transform feedback.

This patch addresses case (a) by changing
intel_batchbuffer_emit_mi_flush() so that on Gen6+, it sets the
PIPE_CONTROL_CS_STALL bit (this forces the pipeline to actually
flush).  (Case (b) will be addressed by the next patch in the series).

This is not an ideal solution--in a perfect world, the driver would
have some buffer dependency tracking so that we would only have to
flush the pipeline in the two cases above.  Until that dependency
tracking is implemented, however, it seems prudent to have
intel_batchbuffer_emit_mi_flush() actually flush the pipeline, so that
we get correct rendering, at the expense of a (hopefully small)
performance hit.

The change is only applied to Gen6+, since at the moment only Gen6+
supports the OpenGL 3.0 features that make a full pipeline flush
necessary.

Reviewed-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>
Reviewed-by: Eric Anholt <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@anholt.net>

bkaradzic/glsl-optimizer,jbarczak/glsl-optimizer,tokyovigilante/glsl-optimizer,zz85/glsl-optimizer,benaadams/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,dellis1972/glsl-optimizer,dellis1972/glsl-optimizer,mapbox/glsl-optimizer,zeux/glsl-optimizer,wolf96/glsl-optimizer,mapbox/glsl-optimizer,benaadams/glsl-optimizer,jbarczak/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer,zeux/glsl-optimizer,dellis1972/glsl-optimizer,bkaradzic/glsl-optimizer,mapbox/glsl-optimizer,benaadams/glsl-optimizer,zz85/glsl-optimizer,metora/MesaGLSLCompiler,tokyovigilante/glsl-optimizer,bkaradzic/glsl-optimizer,jbarczak/glsl-optimizer,bkaradzic/glsl-optimizer,djreep81/glsl-optimizer,wolf96/glsl-optimizer,mcanthony/glsl-optimizer,djreep81/glsl-optimizer,dellis1972/glsl-optimizer,mapbox/glsl-optimizer,mapbox/glsl-optimizer,bkaradzic/glsl-optimizer,mcanthony/glsl-optimizer,zeux/glsl-optimizer,jbarczak/glsl-optimizer,wolf96/glsl-optimizer,metora/MesaGLSLCompiler,djreep81/glsl-optimizer,benaadams/glsl-optimizer,mcanthony/glsl-optimizer,djreep81/glsl-optimizer,benaadams/glsl-optimizer,wolf96/glsl-optimizer,mcanthony/glsl-optimizer,zz85/glsl-optimizer,benaadams/glsl-optimizer,djreep81/glsl-optimizer,zeux/glsl-optimizer,zz85/glsl-optimizer,mcanthony/glsl-optimizer,dellis1972/glsl-optimizer,tokyovigilante/glsl-optimizer,metora/MesaGLSLCompiler,zz85/glsl-optimizer,zeux/glsl-optimizer,tokyovigilante/glsl-optimizer