hiz: Add piglitutil to linker

libhiz-util uses symbols from libpiglitutil but wasn't linked to it.
That worked in linux because linker --no-undefined wasn't passed to
linker. But tests in Mac caught the missing library dependecy.

I now checked with ldd -r that no libraries or binaries have undefined
symbols in my system..

Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Tested-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50708
util: Generalize piglit_probe_image_{rgb,rgba}

This patch eliminates code duplication between
piglit_probe_image_rgb() and piglit_probe_image_rgba() by implementing
them both in terms of a common function, piglit_probe_image_color().
In addition to being able to test GL_RGB and GL_RGBA,
piglit_probe_image_color() should be able to test any color buffer
format (e.g. GL_RG or GL_LUMINANCE_ALPHA).

piglit_probe_image_color() makes use of a new function,
piglit_num_components(), to determine how many components a given base
internal format contains (e.g. piglit_num_components(GL_RGBA) == 4).
This function is exposed through piglit-util.h in case it can be
useful in writing tests.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Acked-by: Marek Olšák <maraeo@gmail.com>
fbo: Make fbo-formats.h able to be included from a .cpp file.

This required changing format_desc::name to a const char *, renaming a
variable called "new", and fixing a few signed/unsigned comparison
warnings.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
fbo: Add base internal format info to fbo-formats.h

This patch augments the format_desc structure (used by fbo-formats.h
to describe a format to be tested) with a base_internal_format field,
which indicates the base internal format corresponding to each
particular internal format (e.g. the base internal format of
GL_R3_G3_B2 is GL_RGB).

The field test_desc::base (which carries the same information, but
only for depth/stencil formats, and is sometimes incorrect) will be
removed in a later patch.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
fbo: Rearrange if tests for GL_DEPTH32F_STENCIL8 behaviour.

The tests fbo-clear-formats and fbo-generatemipmap-formats need
special behaviour for GL_DEPTH32F_STENCIL8.  This patch rearranges the
if statements that implement that special behaviour so that they no
longer rely on the fact that GL_DEPTH32F_STENCIL8 is (incorrectly)
categorized as having a base internal format of GL_DEPTH_COMPONENT
rather than GL_DEPTH_STENCIL.  This will allow the incorrect
categorization to be removed in a future patch.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
fbo: Use format_desc::base_internal_format rather than test_desc::base.

The field test_desc::base has two disadvantages: (1) it is only
populated for depth and depth/stencil formats (for all other formats
it is zero).  (2) it misclassifies GL_DEPTH32F_STENCIL8 as having a
base format of GL_DEPTH_COMPONENT, when the correct base format is
GL_DEPTH_STENCIL.

This patch replaces all references to test_desc::base with
format_desc::base_internal_format, which doesn't have either of these
disadvantages.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
fbo: Remove test_desc::base.

The field test_desc::base is no longer used.  This patch removes it
and simplifies the type signatures of the functions that previously
used it.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
fbo: Eliminate unnecessary variable test_set.

The only purpose of the test_set variable was to point to
test_sets[test_index], but it was not consistently updated.  This
patch replaces it with explicit references to test_sets[test_index] to
reduce confusion.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
fbo: Split out a function for selecting an fbo test set by name.

This patch extracts code from fbo_formats_init() into a separate
function, fbo_lookup_test_set(), whose only purpose is to find an FBO
test set given its name.  This will make it easier for future tests to
make use of fbo-formats.h even if they have to use different
command-line parsing than what is implemented in fbo_formats_init().

This is also one behavioural change: previously, if multiple
command-line arguments were specified to fbo_formats_init(), it would
ignore all but the last.  This was clearly an unintended and
unnecessary behaviour, so I've replaced it with an error message.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
fbo: Make an alternate function for initializing fbo-formats.h.

This patch extracts code from fbo_formats_init() into a separate
function, fbo_formats_init_test_set(), which skips command line
parsing and simply initializes fbo-formats.h to use a particular test
set.  This will allow future tests to make use of fbo-formats.h even
if they have to use different command-line parsing than what is
implemented in fbo_formats_init().

In addition, fbo_formats_init() has been changed to a non-static
function, so that if an fbo test directly calls
fbo_formats_init_test_set() instead, we won't get a spurious compile
warning about an unused function.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Add ColorGradientSunburst program.

This patch adds a new program to the common infrastructure for MSAA
tests, ColorGradientSunburst, which draws a triangle sunburst where
the color of each triangle is a gradient.  This program will be used
to verify proper operation of MSAA when applied to color buffer
formats.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Make a data structure for fbo config.

This patch creates a data structure to contain the configuration
parameters passed to Fbo::init().  This allows obscure parameters
(attach_texture and combine_depth_stencil) to take on default values
in all tests except those that need to give them special treatment.
This will be especially important when future patches in the series
add more obscure configuration parameters.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Reuse FboConfig data structure in Fbo.

This patch modifies Fbo so that instead of storing its copy of the
configuration parameters passed to init() as primitive values, it
stores them using an FboConfig data structure.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Make a separate Fbo setup() function.

This patch splits the function Fbo::set_samples() into two functions,
Fbo::set_samples() (which sets the number of samples and then updates
the framebuffer object to reflect the contents of Fbo::config), and
Fbo::setup() (which simply updates the framebuffer object to reflect
the contents of Fbo::config).  This lets us avoid a clumsy call to
Fbo::set_samples() from Fbo::init().

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Fix GL object leak when changing fbo config.

Previously, we would allocate new textures and renderbuffers whenever
the configuration of a framebuffer changed (e.g. when changing its
sample count), causing the old textures and renderbuffers to be
leaked.  This patch fixes the leak by allocating all of the textures
and renderbuffers that will be needed up front.  It also renames the
generate() function to generate_gl_objects() to clarify its purpose.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Make it possible to reconfigure the fbo after initial use.

This patch makes it safe to re-initialize the state of an Fbo object
to a new configuration.  This will be necessary to allow this object
to be used for testing formats, since one piglit test will have to
test several different Fbo formats in sequence.

To reflect the fact that initialization of the Fbo object is no longer
a one-time action, we now use the name setup() for the function that
sets the Fbo state, rather than init().

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Allow format of the color buffer used in the MSAA fbos to be configured.

This will make it possible to test proper operation of MSAA with
various color buffer formats.  For tests that don't need to vary the
color buffer format, a default format of GL_RGBA is used.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Make a new Fbo::try_setup() function.

In contrast to the Fbo::setup() function (which terminates the test if
the framebuffer is incomplete), Fbo::try_setup() merely returns a
boolean indicating whether the framebuffer is complete.  This will be
necessary to allow different color formats to be tested, since we
won't want to terminate the test if a non-renderable color format is
attempted.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Fix const correctness of TestPattern::draw() function.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Make a static identity matrix for convenience.

This patch adds a constant matrix TestPattern::no_projection (which is
the identity matrix), for use by tests that don't need to pass a
projection matrix when calling TestPattern::draw().

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>