wayland: Don't leak wl_drm global when unbinding display
mesa/tests: Add simple, dumb test for _mesa_program_state_string

After some discussions about the correct way to update
_mesa_program_state_string, I decided to make a unit test for the
function.  It turns out that the function didn't work quite the way I
thought.  The unit test proves that the code was already correct.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: Anuj Phogat <anuj.phogat@gmail.com>
glsl: When constructing a variable with an interface type, set interface_type

Ever since the addition of interface blocks with instance names, we have
had an implicit invariant:

    var->type->is_interface() ==
        (var->type == var->interface_type)

The odd use of == here is intentional because !var->type->is_interface()
implies var->type != var->interface_type.

Further, if var->type->is_array() is true, we have a related implicit
invariant:

    var->type->fields.array->is_interface() ==
        (var->type->fields.array == var->interface_type)

However, the ir_variable constructor doesn't maintain either invariant.
That seems kind of silly... and I tripped over it while writing some
other code.  This patch makes the constructor do the right thing, and it
introduces some tests to verify that behavior.

v2: Add general-ir-test to .gitignore.  Update the description of the
ir_variable invariant for arrays in the commit message.  Both suggested
by Paul.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl/tests: Verify vertex shader built-ins generated by _mesa_glsl_initialize_variables

Checks that the variables generated meet certain criteria.

 - Vertex shader inputs have an explicit location.

 - Vertex shader outputs have an explicit location.

 - Fragment shader-only varying locations are not used.

 - Vertex shader uniforms and system values don't have an explicit
   location.

 - Vertex shader constants don't have an explicit location and are
   read-only.

 - No other kinds of vertex variables exist.

It does not verify that an specific variables exist.

v2: Fix memory management mistakes in
common_builtin::string_starts_with_prefix.  Clean up error message
reporting in common_builtin::no_invalid_variable_modes.  Both suggested
by Paul.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl/tests: Verify fragment shader built-ins generated by _mesa_glsl_initialize_variables

Checks that the variables generated meet certain criteria.

 - Fragment shader inputs have an explicit location.

 - Fragment shader outputs have an explicit location.

 - Vertex / geometry shader-only varying locations are not used.

 - Fragment shader uniforms and system values don't have an explicit
   location.

 - Fragment shader constants don't have an explicit location and are
   read-only.

 - No other kinds of fragment variables exist.

It does not verify that an specific variables exist.

v2: Use _mesa_varying_slot_in_fs in
fragment_builtin.inputs_have_explicit_location.  Suggested by Paul.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl/tests: Verify geometry shader built-ins generated by _mesa_glsl_initialize_variables

Checks that the variables generated meet certain criteria.

 - Geometry shader inputs have an explicit location.

 - Geometry shader outputs have an explicit location.

 - Fragment shader-only varying locations are not used.

 - Geometry shader uniforms and system values don't have an explicit
   location.

 - Geometry shader constants don't have an explicit location and are
   read-only.

 - No other kinds of geometry variables exist.

It does not verify that an specific variables exist.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl: Modify interface to link_invalidate_variable_locations

This will make it easier to unit test this function in successive
patches.  Also, correct the prototype in linker.h.  It was... wrong.

v2: Split the interface change from adding the unit tests.  Suggested by
Paul.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl/tests: Unit test vertex shader in / out with link_invalidate_variable_locations

Validates:

  - ir_variable::explicit_location should not be modified.

  - If ir_variable::explicit_location is not set, ir_variable::location,
    ir_variable::location_frac, and
    ir_variable::is_unmatched_generic_inout must be reset to 0.

  - If ir_variable::explicit_location is set, ir_variable::location
    should not be modified.  ir_variable::location_frac, and
    ir_variable::is_unmatched_generic_inout must be reset to 0.
    Previous unit tests have shown that all non-generic inputs / outputs
    have explicit_location set.

v2: Split the link_invalidate_variable_locations interface change out to
a separate patch.  Remove the vertex_in_builtin_without_explicit and
vertex_out_builtin_without_explicit tests.  There was a lot of good
discussion about this on the mailing list to which I refer the
interested reader.  Both changes suggested by Paul.

    http://lists.freedesktop.org/archives/mesa-dev/2013-October/046652.html

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl: Simplify the interface to link_invalidate_variable_locations

The unit tests added in the previous commits prove some things about the
state of some internal data structures.  The most important of these is
that all built-in input and output variables have explicit_location
set.  This means that link_invalidate_variable_locations doesn't need to
know the range of non-generic shader inputs or outputs.  It can simply
reset location state depending on whether explicit_location is set.

There are two additional assumptions that were already implicit in the
code that comments now document.

  - ir_variable::is_unmatched_generic_inout is only used by the linker
    when connecting outputs from one shader stage to inputs of another
    shader stage.

  - Any varying that has explicit_location set must be a built-in.  This
    will be true until GL_ARB_separate_shader_objects is supported.

As a result, the input_base and output_base parameters to
link_invalidate_variable_locations are no longer necessary, and the code
for resetting locations and setting is_unmatched_generic_inout can be
simplified.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
i965: Move flushing out of write_reg and into the callers.

The current callers just want to write a single register, so combining
the register read with a pipeline flush made sense.  However, in the
future we'll want to do multiple register reads back to back, and we'll
only want to flush once.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
i965: Expose write_reg() as brw_store_register_mem64().

Writing a 64-bit register value to memory is sufficiently complicated
that it makes sense to reuse this function rather than duplicating it.

Exposing it outside of gen6_queryobj.c means it needs a more descriptive
function name.  It could probably be moved to brw_util.c or somewhere
else, but this works too.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
svga: remove unneeded include of u_double_list.h
gallium: new, unified pipe_context::set_sampler_views() function

The new function replaces four old functions: set_fragment/vertex/
geometry/compute_sampler_views().

Note: at this time, it's expected that the 'start' parameter will
always be zero.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Emil Velikov <emil.l.velikov@gmail.com>
radeonsi: remove unused si_set_cs_sampler_view()

Fixes build breakage.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70804

Tested-by: Vinson Lee <vlee@freedesktop.org>
nv50: clamp PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS to PIPE_MAX_SAMPLERS

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70212
Tested-by: Aaron Watry <awatry@gmail.com>
clover: fix build after a3ed98f7aa85636579a5696bf036ec13e5c9104a
i965: Fix texture buffer rendering after a whole buffer replacement.

If glBufferData(), glBufferSubData(0, obj->Size), or similar happens, we
get a new drm_intel_bo for the buffer object, and thus need to re-upload
texture buffer state so we point at the new data.

Fixes the new piglit GL_ARB_texture_buffer_object/data-sync

Cc: "9.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
i965: Drop intel_bufferobj_source().

Since src_offset was always 0, it wasn't doing anything for us beyond
intel_bufferobj_buffer().

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
i965: Add a note about the late-allocation in intel_bufferobj_buffer().

This was mostly for the i915 system-memory VBO code, which we don't have
any more, but since that existed we've ended up producing dependencies on
it being there.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
i965: Add support for GL_ARB_texture_buffer_range.

Supporting this extension turns out to simplify our code a bit over not
supporting this extension, once the glBufferSubData() synchronization code
lands.

v2: Use 16 byte alignment like we do for uniform buffers, due to unaligned
    access penalties.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> (v1)