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>
msaa: Refactor all.tests so that sample counts to test are specified once.
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.
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.
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.
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.
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.
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.
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.
msaa/formats: Compare integer formats properly.

This patch adapts the MSAA "formats" test to use
piglit_compare_images_color() to check pass/fail instead of
piglit_probe_image_color().  This will allow integer formats to be
tested.
msaa/formats: Use a scale and offset for testing integer formats.

This patch adapts the MSAA "formats" test so that when drawing into
integer framebuffers, it applies the necessary scale and offset to
cover the entire range of possible integer values.  When reading
pixels back from the framebuffer, the test applies the inverse scale
and offset, so that the result can be compared to the reference RGBA
image.
msaa/formats: Make it possible to specify a test set on the command line.
msaa/formats: Add EXT_texture_integer tests.

The MSAA "formats" test now properly tests integer framebuffer
formats.  This patch updates all.tests to cause integer framebuffer
formats to be tested.
msaa/formats: Adjust tolerance appropriately for floating-point formats.

When setting up a floating-point format, the GL implementation
responds to queries GL_ATTACHMENT_{RED,GREEN,BLUE,ALPHA}_SIZE with the
total number of bits in the floating-point value, regardless of
whether those bits are used for sign, exponent, or mantissa.  However,
for the purpose of setting a reasonable tolerance for pass/fail
comparisons, we really should only account for mantissa bits.

This patch modifies the MSAA "formats" test to detect when the buffer
format is GL_FLOAT, and if so, convert the channel size into the
number of mantissa bits, so that we don't test floating-point formats
to an unreasonably tight tolerance.