radeonsi/compute: fix bind_compute_sampler_states() breakage

Remove the assignment and the no-op function.
configure: set HAVE_COMMON_DRI when building only swrast

With commit cb1febb07, I have incorrectly removed HAVE_COMMON_DRI
assuming that swrast does not need to build the translations for
driconf options, as effectively swrast/drisw does not use them.

With the incoming unification work of dri and drisw, it makes
sense just to revert the offending hunk.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70057
Reported-by: Vinson Lee <vlee@freedesktop.org>
Tested-by: Vinson Lee <vlee@freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
radeonsi: Fix build

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>

https://bugs.freedesktop.org/show_bug.cgi?id=70106
radeonsi/compute: Fix segfault caused by recent refactoring

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
util: when packing depth values, round to nearest.

This patch adds the lrint, lrintf, llrint, and llrintf rounding utility
functions. When packing unorm depth values, we will round to nearest.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
svga: fix incorrect memcpy src in svga_buffer_upload_piecewise()

As we march over the source buffer we're uploading in pieces, we
need to memcpy from the current offset, not the start of the buffer.
Fixes graphical corruption when drawing very large vertex buffers.

Cc: "9.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Matthew McClure <mcclurem@vmware.com>
glsl: Add parser support for unsized arrays in interface blocks.

Although it's not explicitly stated in the GLSL 1.50 spec, unsized
arrays are allowed in interface blocks.

section 1.2.3 (Changes from revision 5 of version 1.5) of the GLSL
1.50 spec says:

    * Completed full update to grammar section.  Tested spec examples
      against it:

      ...

      * add unsized arrays for block members

And section 7.1 (Vertex and Geometry Shader Special Variables)
includes an unsized array in the built-in gl_PerVertex interface
block:

    out gl_PerVertex {
        vec4 gl_Position;
        float gl_PointSize;
        float gl_ClipDistance[];
    };

Furthermore, GLSL 4.30 contains an example of an unsized array
occurring inside an interface block.  From section 4.3.9 (Interface
Blocks):

    uniform Transform {  // API uses "Transform[2]" to refer to instance 2
        mat4           ModelViewMatrix;
        mat4           ModelViewProjectionMatrix;
        vec4           a[];  // array will get implicitly sized
        float          Deformation;
    } transforms[4];

This patch adds the parser rule to support unsized arrays inside
interface blocks.  Later patches in the series will add the
appropriate semantics to handle them.

Fixes piglit tests:
- spec/glsl-1.50/execution/unsized-in-unnamed-interface-block
- spec/glsl-1.50/linker/unsized-in-unnamed-interface-block
glsl: Link uniform-initializer-test with standalone_scaffolding.cpp.

Future patches in this series will add calls to _mesa_glsl_error() to
ir.cpp.  _mesa_glsl_error() calls _mesa_glsl_msg(), which calls
_mesa_shader_debug(), which is defined in mesa/main/errors.c (and
hence not available when compiling GLSL unit tests).  To avoid link
errors, link uniform-initializer-test with standalone_scaffolding.cpp,
which also provides _mesa_shader_debug().
glsl: Move update of max_array_access into a virtual function on ir_rvalue.

Currently, when converting an access to an array element from ast to
IR, we need to see if the array is an ir_dereference_variable, and if
so update the variable's max_array_access.

When we add support for unsized arrays in interface blocks, we'll also
need to account for cases where the array is an ir_dereference_record
and the record is an interface block.

To make this easier, move the update into a virtual function on
ir_value, so that the appropriate logic will get invoked based on the
rvalue's type.
glsl: Make accessor functions for ir_variable::interface_type.

In a future patch, this will allow us to enforce invariants when the
interface type is updated.
glsl: Add an ir_variable::max_ifc_array_access field.

For interface blocks that contain arrays, this field will contain the
maximum element of each contained array that is accessed by the
shader.  This is a first step toward supporting unsized arrays in
interface blocks.
glsl: Sanity check max_ifc_array_access in ir_validate::visit(ir_variable *).
glsl: Update ir_variable::max_ifc_array_access properly.

This patch adds an implementation of
ir_dereference_record::update_max_array_access(), which ensures that
ir_variable::max_ifc_array_access is properly updated to reflect the
shader's use of arrays appearing within interface blocks.
glsl/linker: Modify array_sizing_visitor to handle named interface blocks.

Unsized arrays appearing inside named interface blocks now get a
proper size assigned by the array_sizing_visitor.

Fixes piglit tests:
- spec/glsl-1.50/execution/unsized-in-named-interface-block
- spec/glsl-1.50/execution/unsized-in-named-interface-block-gs
- spec/glsl-1.50/linker/unsized-in-named-interface-block
- spec/glsl-1.50/linker/unsized-in-named-interface-block-gs
- spec/glsl-1.50/linker/unsized-in-unnamed-interface-block-gs (*)

(*) is fixed by dumb luck--support for unsized arrays in unnamed
interface blocks will come in a later patch.
glsl: Update call_link_visitor to update max_ifc_array_access.

When multiple shaders of the same type access an interface block
containing an unsized array, we need to set the array size based on
the maximum array element accessed across all the shaders.  This is
similar to what we already do with unsized arrays occurring outside of
interface blocks.

Note: one corner case is not yet addressed by these patches: the case
where one compilation unit defines an interface block containing
unsized arrays and another compilation unit defines the same interface
block containing sized arrays.

Fixes piglit test:
- spec/glsl-1.50/execution/unsized-in-named-interface-block-multiple
glsl: Modify array_sizing_visitor to handle unnamed interface blocks.

We were already setting the array size of unsized arrays that appeared
inside unnamed interface blocks, but we weren't updating
ir_variable::interface_type to reflect the new array size, causing
bogus link errors.

This patch causes array_sizing_visitor to keep track of all the
unnamed interface types it sees, and the ir_variables corresponding to
each one.  After the visitor runs, a new function,
fixup_unnamed_interface_types(), adjusts each unnamed interface type
to correctly correspond with the array sizes in the ir_variables.

Fixes piglit tests:
- spec/glsl-1.50/execution/unsized-in-unnamed-interface-block-gs
- spec/glsl-1.50/execution/unsized-in-unnamed-interface-block-multiple
glsl: Keep track of location for interface block fields.

This patch adds a "location" element to struct glsl_struct_field, so
that we can keep track of the gl_varying_slot associated with each
built-in geometry shader input.

In lower_named_interface_blocks, we use this value to populate the
"location" field in the ir_variable that stores each geometry shader
input.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
glsl/gs: add gl_in support to builtin_variables.cpp.

Previously, builtin_variables.cpp was written assuming that we
supported ARB_geometry_shader4 style geometry shader inputs, meaning
that each built-in varying input to a geometry was supplied via an
array variable whose name ended in "In", e.g. gl_PositionIn or
gl_PointSizeIn.

However, in GLSL 1.50 style geometry shaders, things work
differently--built-in inputs are supplied to geometry shaders via a
built-in interface block called gl_in, which contains all the built-in
inputs using their usual names (e.g. the gl_Position input is supplied
to the geometry shader as gl_in[i].gl_Position).

This patch adds the necessary logic to builtin_variables.cpp to create
the gl_in interface block and populate it accordingly for geometry
shader inputs.  The old ARB_geometry_shader4 style varyings are
removed, though they can easily be added back in the future if we
decide to support ARB_geometry_shader4.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
glsl/gs: handle gl_ClipDistance geometry input in lower_clip_distance.

This corresponds to the lowering of gl_ClipDistance to
gl_ClipDistanceMESA for vertex and geometry shader outputs.  Since
this lowering pass occurs after lower_named_interface blocks, it deals
with 2D arrays (gl_ClipDistance[vertex][clip_plane]) rather than 1D
arrays in an interface block
(gl_in[vertex].gl_ClipDistance[clip_plane]).

v2 (Paul Berry <stereotype441@gmail.com>): Fix indexing order for
gl_ClipDistance input lowering.  Properly lower bulk assignment of
gl_ClipDistance inputs.  Rework for GLSL 1.50 style geometry shaders.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
i965/gs: Fixup gl_PointSize on entry to geometry shaders.

gl_PointSize is stored in the w component of VARYING_SLOT_PSIZ, but
the geometry shader infrastructure assumes that it should look for all
geometry shader inputs of type float in the x component.  So when
compiling a geomtery shader that uses a gl_PointSize input, fix it up
during the shader prolog by moving the w component to the x component.

This is similar to how we emit fixups and workarounds for vertex
shader attributes.

Fixes piglit test spec/glsl-1.50/execution/geometry/core-inputs.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>