Revert "i965: Disable unused pipeline stages once at startup on Gen7+."

This reverts commit 6c966ccf07bcaf64fba1a9b699440c30dc96e732.

Apparently causes GPU hangs.

Conflicts:
	src/mesa/drivers/dri/i965/brw_state.h
	src/mesa/drivers/dri/i965/brw_state_upload.c
draw: make sure clipdistances work with geometry shaders

we were always fetching the info from the vertex shader, but if
geometry shader is present it should be used as the source of
that info.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
draw: enable user plane clipping when clipdistance is used

Draw depended on clip_plane_enable being set in the rasterizer
to use clipdistance registers for clipping. That's really
unfriendly because it requires that rasterizer state to have
variants for every shader out there. Instead of depending on
the rasterizer lets extract the info from the available state:
if a shader writes clipdistance then we need to use it and we
need to clip using a number of planes equal to the number
of writen clipdistance components. This way clipdistances
just work.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
draw: fix clipper invocation statistics

We need to figure out the number of invocations of the clipper
before the emit, because in the emit we are after clipping
where the number of primitives will be equal to number of clipper
invocations minus the clipped primitives. So our computations
were always off by the number of clipped primitives.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
gallium: add a cull distance semantic

cull distance is analogous to clip distance. If a register is
given this semantic, then the values in it are assumed to be a
float32 distance to a plane. Primitives will be completely
discarded if the plane distance for all of the vertices in
the primitive are < 0.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
draw: implement distance culling

Works similarly to clip distance. If the cull distance is negative
for all vertices against a specific plane then the primitive
is culled.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
i965: Emit the BLEND_STATE pointer directly rather than via atoms.

Previously, we would:
1. Emit the new indirect state.
2. Flag CACHE_NEW_BLEND_STATE.
3. Rely on later state atoms to notice CACHE_NEW_BLEND_STATE and emit a
   pointer to the new indirect state.

This is rather cumbersome: it requires two state atoms instead of one,
and there's a strict ordering dependency in the list.  Plus, the code
gets spread across two functions (or even files in the case of Gen7+).

Gen7+ has a packet to update just the blend state pointer, so it makes a
lot of sense to simply emit that right away.  Gen6 has a combined packet
which updates blending, the color calculator, and depth/stencil state;
however, each can still be modified independently.

This drops the Gen6 micro-optimization where we tried to only emit one
packet that changed all three states.  State updates are pretty cheap.

CACHE_NEW_BLEND_STATE is no longer necessary, so drop it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Emit the CC state pointer directly rather than via atoms.

See the previous commit for the rationale.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
i965: Emit the depth/stencil state pointer directly, not via atoms.

See two commits ago for the rationale.  This allows us to delete the
whole gen7_cc_state.c file.

This does move these commands before the depth stall flushes from
brw_emit_depthbuffer, which may be a problem.  The documentation for
3DSTATE_DEPTH_BUFFER mentions that depth stall flushes are required
before changing any depth/stencil buffer state, but explicitly lists
3DSTATE_DEPTH_BUFFER, 3DSTATE_HIER_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER,
and 3DSTATE_CLEAR_PARAMS.  It does not mention this particular packet
(_3DSTATE_DEPTH_STENCIL_STATE_POINTERS).

No observed Piglit regressions on Sandybridge or Ivybridge.

Together with the last two commits, this makes a cairo-gl benchmark
faster by 0.324552% +/- 0.258355% on Ivybridge.  No statistically
significant change on Sandybridge.  (Thanks to Eric for the numbers.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
ilo: remove unnecessary tex_set_bo/buf_set_bo

Merge the bodies to tex_create_bo/buf_create_bo respectively.
ilo: access bo size directly

buf->bo_size is readily avaiable, no need to go via buf->bo->get_size().
ilo: get rid of function tables in winsys

We are moving toward making struct intel_bo alias drm_intel_bo.  As a first
step, we cannot have function tables.
ilo: update winsys interface

The motivation is to kill tiling and pitch in struct intel_bo.  That requires
us to make tiling and pitch not queryable, and be passed around as function
parameters.
winsys/intel: reorganize functions

Move functions around to match the order of the declarations in the header.
winsys/intel: make struct intel_bo alias drm_intel_bo

There is really nothing in struct intel_bo, and having it alias drm_intel_bo
makes the winsys impose almost zero overhead.

We can make the overhead gone completely by making the functions static
inline, if needed.