mtypes.h: Modify gl_vert_result to refer to new gl_varying_slot enum.

This paves the way for eliminating the gl_vert_result enum entirely.
Replace gl_vert_result enum with gl_varying_slot.

This patch makes the following search-and-replace changes:

gl_vert_result -> gl_varying_slot
VERT_RESULT_* -> VARYING_SLOT_*
mtypes.h: Modify gl_geom_attrib to refer to new gl_varying_slot enum.

This paves the way for eliminating the gl_geom_attrib enum entirely.
Replace gl_geom_attrib enum with gl_varying_slot.

This patch makes the following search-and-replace changes:

gl_geom_attrib -> gl_varying_slot
GEOM_ATTRIB_* -> VARYING_SLOT_*
GEOM_BIT_* -> VARYING_BIT_*
mtypes.h: Modify gl_geom_result to refer to new gl_varying_slot enum.

This paves the way for eliminating the gl_geom_result enum entirely.
Replace gl_geom_result enum with gl_varying_slot.

This patch makes the following search-and-replace changes:

gl_geom_result -> gl_varying_slot
GEOM_RESULT_* -> VARYING_SLOT_*
mtypes.h: Modify gl_frag_attrib to refer to new gl_varying_slot enum.

This paves the way for eliminating the gl_frag_attrib enum entirely.
Get rid of _mesa_vert_result_to_frag_attrib().

Now that there is no difference between the enums that represent
vertex outputs and fragment inputs, there's no need for a conversion
function.  But we still need to be able to detect when a given vertex
output has no corresponding fragment input.  So it is replaced by a
new function, _mesa_varying_slot_in_fs(), which tells whether the
given varying slot exists as an FS input or not.
Get rid of _mesa_frag_attrib_to_vert_result().

Now that there is no difference between the enums that represent
vertex outputs and fragment inputs, there's no need for a conversion
function.
Replace gl_frag_attrib enum with gl_varying_slot.

This patch makes the following search-and-replace changes:

gl_frag_attrib -> gl_varying_slot
FRAG_ATTRIB_* -> VARYING_SLOT_*
FRAG_BIT_* -> VARYING_BIT_*
i965: Apply depthstencil alignment workaround when doing fast clears.

Fast depth clears have the same depth/stencil alignment requirements
as other drawing operations.  Therefore, we need to call
brw_workaround_depthstencil_alignment() from both the clear and
drawing paths.

Without this fix, we get image corruption if the following conditions
hold: (a) the first ever drawing operation to a depth miplevel (or the
first drawing operation after having used the texture for sampling) is
a clear, (b) the depth miplevel has a size that is eligible for fast
depth clears, and (c) the depth miplevel has an offset within the
miptree that isn't 8x8 aligned.

Fixes piglit "depthstencil-render-miplevels" tests with size 273.

NOTE: This is a candidate for stable branches
i965: Avoid unnecessary copy when depthstencil workaround invoked by clear.

Since apps typically begin rendering with a call to glClear(), it is
likely that when brw_workaround_depthstencil_alignment() moves a
miplevel to a temporary buffer, it can avoid doing a blit, since the
contents of the miplevel are about to be erased.

This patch adds the necessary plumbing to determine when
brw_workaround_depthstencil_alignment() is being called as a
consequence of glClear(), and avoids the unnecessary blit when it is
safe to do so.
ff_fragment_shader: Don't do unnecessary (and dangerous) uniform setup.

Previously, right after calling _mesa_glsl_link_shader(), the fixed
function fragment shader code made several calls with the ostensible
purpose of setting up uniforms for the fragment shader it just
created.

These calls are unnecessary, since _mesa_glsl_link_shader() calls
driver->LinkShader(), which takes care of calling these functions (or
their equivalent).  Also, they are dangerous to call after
_mesa_glsl_link_shader() has returned, because on back-ends such as
i965 which do precompilation, _mesa_glsl_link_shader() may have
already cached pointers to the existing uniform structures; attempting
to set up the uniforms again invalidates those cached pointers.

It was only by sheer coincidence that this wasn't manifesting itself
as a bug.  It turns out that i965's precompile mechanism was always
setting bit 0 of brw_wm_prog_key::proj_attrib_mask to 0 for fixed
function fragment shaders, but during normal usage this bit usually
gets set to 1.  As a result, the precompiled shader (with its invalid
uniform pointers) was not being used.

I'm about to introduce some changes that cause bit 0 of
proj_attrib_mask to be set consistently between precompilation and
normal useag, so to avoid regressions I need to get rid of the
dangerous duplicate uniform setup code first.
i965/fs: Avoid unnecessary recompiles due to WPOS bit of proj_attrib_mask.

Previous to this patch, when using fixed function fragment shading,
bit FRAG_BIT_WPOS of brw_wm_prog_key::proj_attrib_mask was being set
differently during precompiles and normal usage.  During precompiles
it was being set only if the fragment shader reads from window
position (which it never does), so it was always being set to 0.
During normal usage it was being set if the vertex shader writes to
all 4 components of gl_Position (which it usually does), so it was
usually being set to 1.  As a result, we were almost always doing an
extra recompile for the fixed function fragment shader.

The recompile was totally unnecessary, though, because
brw_wm_prog_key::proj_attrib_mask is only consulted for
fs_visitor::emit_general_interpolation(), which isn't used for
FRAG_ATTRIB_WPOS.

This patch avoids the unnecessary recompile by always setting bit
FRAG_BIT_WPOS of brw_wm_prog_key::proj_attrib_mask to 1.
i965/pre-Gen6: Don't rely on VERT_RESULT_HPOS <-> FRAG_ATTRIB_WPOS.  TODO: maybe no longer needed.

At present, the _mesa_vert_result_to_frag_attrib() and
_mesa_frag_attrib_to_vert_result() functions establish a
correspondence between VERT_RESULT_HPOS and FRAG_ATTRIB_WPOS.  This is
bogus, since the former is gl_Position and the later is gl_FragCoord,
which aren't in any way the same thing.

Only one piece of code relied on this clumsy correspondence--the
determination of which fragment inputs are present when computing the
urb_setup for pre-Gen6 fragment shaders.  This patch modifies the
urb_setup computation so that it always assumes FRAG_ATTRIB_WPOS is
present (because it always is).
!UPSTREAM: Hacky fix for Gen5 depthstencil-render-miplevels stencil-only test.  TODO: think through, test thoroughly, and document.