glsl: fix several use-after-free bugs

The get_variable_being_redeclared() function can free the 'var' argument.
Thereafter, we cannot assume that 'var' is a valid  pointer.  This patch
replaces 'var->name' with 'earlier->name' in two places and calls
is_gl_identifier(var->name) before 'var' might get freed.

This fixes several piglit GLSL crashes, including:
spec/glsl-1.50/execution/geometry/clip-distance-in-param
spec/glsl-1.50/execution/geometry/clip-distance-bulk-copy
spec/glsl-1.50/compiler/gs-redeclares-pervertex-out-before-global-redeclaration.geom

I'm not sure why these were not spotted sooner.
A similar bug was previously fixed by f9cecca7a.

Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: fix 'misalgned' typos in error messages

Trivial.
mesa: fix 'feeedback' typo in comment

Trivial.
freedreno/a3xx: more layer/level fixes

Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/a3xx: only emit dirty consts

If app only updates (for example) vertex uniforms, it would be nice to
only re-emit those and not also frag uniforms.  Means we need to mark
the first frag shader const buffer dirty after a clear.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/ir3: comment + better fxn name

Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/ir3: fix potential gpu lockup with kill

It seems like the hardware is unhappy if we execute a kill instruction
prior to last input (ei).  Probably the shader thread stops executing
and the end-input flag is never set.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/a3xx: disable early-z when we have kill's

Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno: positions come out as integers, not half-integers

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/ir3: add debug flag to disable cp

FD_MESA_DEBUG=nocp will disable copy propagation pass.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
vc4: Don't look at back stencil state unless two-sided stencil is enabled.

Fixes regressions in the next bugfix, because gallium util stuff leaves
the back stencil state as 0 if !back->enabled.
vc4: Fix stencil writemask handling.

If the writemask doesn't compress, then we want to put in the uncompressed
writemask, not the compressed writemask failure value (all-on).

Fixes glean's stencil2 and fbo-clear-formats on stencil.
vc4: Fix SRC_ALPHA_SATURATE blending.

Fixes glean blendFunc.
gallium: add PIPE_SHADER_CAP_MAX_OUTPUTS and use it in st/mesa

With 5 shader stages and various combinations of enabled and disabled shaders,
the maximum number of outputs in one shader doesn't have to be equal to
the maximum number of inputs in the following shader.

v2: return 32 for softpipe and llvmpipe
st/mesa: add ST_DEBUG=wf option which enables wireframe rendering

Useful for tessellation.
glsl_to_tgsi: fix the value of gl_FrontFacing with native integers

We must convert it to boolean from the DX9 float encoding that Gallium
specifies.

Later, we should probably define that FACE should be 0 or ~0 if native
integers are supported.

Cc: 10.2 10.3 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
glsl_to_tgsi: use _mesa_copy_linked_program_data

This deduplicates some code.
r300g: replace r300_get_num_samples with a util variant
radeonsi: inline si_pm4_alloc_state

It seemed like the function needed a context pointer. Let's remove it
to make it less confusing.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
radeonsi: make pm4 state generation for shaders independent of the context

The si_pm4_delete_state calls became useless, because the pm4 state is
always generated only once.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>