msaa: Fix window width of enable-flag test.

This test was incorrectly converted in the patch "tests: Let each test
define main()".
Test that dFdx/dFdy work properly on fbos

This test exposes a bug in Mesa on i965 hardware (as of commit
f2f05e5): the GLSL function dFdy() produces incorrect results when
rendering to an FBO.  This is a consequence of the fact that FBOs
place the origin at the upper left, whereas windowsystem framebuffers
place the origin at the lower left.

Verified using nVidia's proprietary binary driver for Linux.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
max-texture-size: allow INVALID_VALUE if first TexImage fails with OUT_OF_MEMORY

The GL spec says that the behavior of a command returning OUT_OF_MEMORY is
undefined, therefore the following call to TexSubImage may return INVALID_VALUE.
(e.g. if TexWidth is 0 because the call to TexImage had no effect because
of OUT_OF_MEMORY, then the check "xoffset+width > TexWidth" in TexSubImage will
always set INVALID_VALUE)

Reviewed-by: Brian Paul <brianp@vmware.com>
Add test to verify glSampleCoverage with multisample fbo

This test varifies that the coverage value set by glSampleCoverage() decides
the number of samples in multisample buffer covered by an incoming fragment,
which will receive the fragment data.

V2: Add the testing for glSampleCoverage() with coverage mask invert enabled
    / disabled. Resolve the multisample FBO to a single sample FBO in place
    of doing it on window system framebuffer. This fixes the color buffer
    failures on NVIDIA due to sRGB.

V3: Add testing for coverage values which may result in dithering for all
    sample counts. Dropping the testing for multisample depth buffer.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Add test to verify sample alpha to coverage with multisample fbo

This test varifies that with GL_SAMPLE_ALPHA_TO_COVERAGE enabled, the coverage
value is set by fragment alpha value. Coverage value decides the number of
samples in multisample buffer covered by an incoming fragment, which receive
the fragment data.

It also includes testing of GL_SAMPLE_ALPHA_TO_COVERAGE with GL_SAMPLE_ALPHA_TO_ONE
enabled.

V2: Add testing for coverage values which may result in dithering for all sample
    counts. Dropping the testing for multisample depth buffer.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Add test to verify sample alpha to one with multisample fbo

This test varifies that with GL_SAMPLE_ALPHA_TO_ONE enabled, each sample's
alpha value is replaced by maximum alpha value i.e. 1.0.

Verified the test case using proprietary NVIDIA drivers.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul-Berry <stereotype441@gmail.com>
Add test to verify the functionality of glBitmap() with multisample FBO

glBitmap() is expected to work exactly the same way on multisample FBO as
it works on single sample FBO. Test assumes that MSAA accuracy test already
passes.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Add test to verify the functionality of polygon stipple with multisample FBO

Test assumes that MSAA accuracy test already passes.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
ext_framebuffer_multisample: fix turn-on-off test

Set combine_depth_stencil flag to true while creating multisample FBO.
This is to avoid "Framebuffer not complete" error message with drivers
which don't allow creating separate depth and stencil attachments to
a FBO. e.g. NVIDIA's proprietary drivers.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
ext_framebuffer_multisample: Cast sin arguments to floating point.

To prevent "ambiguous call to overloaded function" error on MSVC.

Trivial.
ext_framebuffer_multisample: Use dynamic array instead of variable length array.

As the later is a GNU extension, not supported on MSVC.

Trivial.
ext_framebuffer_multisample: Use dynamic array instead of variable length array.

As the later is a GNU extension, not supported on MSVC.

Missed in the previous commit.
msaa: Refactor all.tests so that sample counts to test are specified once.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
msaa: Test that msaa blits are clipped and scissored correctly.

There are three reasons why the set of rectangles passed to
glBlitFramebuffer() might need to be clipped before performing the
blit:

1. If the destination rectangle falls (partly or completely) outside
the bounds of the draw framebuffer.

2. If the destination rectangle falls (partly or completely) outside
the scissor rectangle.

3. If the source rectangle falls (party or completely) outside the
bounds of the read framebuffer.

In cases 1 and 2, it is clear from the GL spec that the blit should be
clipped.  In case 3, the spec is less clear, however Ian Romanick and
I have received clarification from the ARB that clipping is the
intended behaviour.

This test verifies that blits are properly clipped in cases 1-3.  It
only tests blits in which the source and destination rectangles are
the same size (i.e. no scaling is occurring), since scaling blits are
not allowed for MSAA.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
glsl-1.30: Verify proper conversion of large floats to uints.

This patch adds two new tests that exercise a bug in Mesa/i965:
conversion from float to uint was being done in a two step process:
convert first to int and then to uint.  Since i965 uses saturating
arithmetic in float->int conversion, this caused conversion to give
the wrong result for values greater than 0x7fffffff.

I'll be submitting a Mesa fix shortly.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
util: Make a separate function to compare in-memory images.

This patch splits off a new piglit-util function,
piglit_compare_images_color(), from the existing
piglit_probe_image_color() function.  The new function compares two
images in memory, so that the caller can take responsibility for
calling glReadPixels().

In addition, this patch creates a function
piglit_compute_probe_tolerance(), which detemines the correct
tolerance thresholds to use when comparing images.

These functions will be needed in order to test proper behaviour of
MSAA with different buffer formats, since the MSAA format test needs
to be able to read the rendered image using glReadPixels, make
adjustments to it in memory, and then compare the results.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Make it possible to change output type when drawing sunbursts.

In order to test that MSAA works properly for integer framebuffers, we
will need to be able to output ivec4 and uvec4 types when rendering
the test image.  This patch makes that possible by adapting the
Sunburst GLSL program so that it can be compiled to output ivec4's,
uvec4's, or vec4's.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Make it possible to scale and offset ColorGradientSunburst.

In order to test that MSAA works properly for integer framebuffers, we
will need to be able to adjust the outputs of the
ColorGradientSunburst program to cover the range of signed or unsigned
integers, rather than the range [0, 1] that is appropriate for testing
normalized color framebuffers.

This patch makes that possible by adding "scale" and "offset"
parameters to the ColorGradientSunburst program.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa/formats: Adapt test pattern drawing to handle integer formats.

This patch adapts the MSAA "formats" test so that it can draw to
integer framebuffers, by creating 3 instantiations of the
ColorGradientSunburst class, one for testing vec4's (for floating
point and normalized formats), one for testing ivec4's (for signed
integer formats), and one for testing uvec4's (for unsigned integer
formats).

The test determines which ColorGradientSunburst to use by querying
GL_FRAMEBUFFERATTACHMENT_COMPONENT_TYPE.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa/formats: Adapt glReadPixels() call to handle integer formats.

This patch adapts the MSAA "formats" test to pass the proper
parameters to glReadPixels() when checking that the proper image has
been rendered.  Since glReadPixels() requires an integral type when
reading pixels from an integer framebuffer, we read the pixels into a
temporary integer buffer and then copy them (using the CPU) into a
floating point buffer for comparison to the reference image.

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