Geometry shaders: Test gl_ClipDistance input (GLSL 1.50)

This patch adds piglit tests to ensure that gl_ClipDistance works
properly as a geometry shader input.

v2: In accordance with GLSL 1.50 requirements, do all re-declarations
of gl_ClipDistance within gl_PerVertex interface block.

Reviewed-by: Fabian Bieler <fabianbieler@fastmail.fm>
Geometry shaders: test gl_ClipDistanceIn (ARB_geometry_shader4)

Since ARB_geometry_shader4 is written against the OpenGL 2.0
specification (which predates gl_ClipDistance), it does not specify
how gl_ClipDistance should be adapted for use in geometry shaders.
However, there is an obvious analogy to the behaviour of gl_TexCoord
(which, like clip distance, is a vertex shader output whose type is a
1D array).  Specifically, the geometry shader should have access to a
2D input array gl_ClipDistanceIn array, where the first index is the
input vertex, and the second index is analogous to the index on
gl_ClipDistance.

This patch adds piglit tests to ensure that gl_ClipDistanceIn works
properly.

Reviewed-by: Fabian Bieler <fabianbieler@fastmail.fm>
Fix clip-distance-explicit-too-large.frag test

The test incorrectly declared gl_ClipDistance as an "out" variable.
This is incorrect--in a fragment shader it should be an "in" variable.

This wasn't causing a piglit failure, since the test was expected to
produce a compile error.  It just means that it wasn't testing what it
was supposed to.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Test that fast color clears are resolved even if front rendering intervenes.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Test a front buffer corner case: invalidate causes data loss.

Cc: Eric Anholt <eric@anholt.net>

v2: Move to spec/gl-1.0.  Add to all.tests.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Add a new test profile: gpu.tests.

Often, I make changes to Mesa which only affect tests that actually
execute on the GPU.  For such changes, there's no real benefit to
running compiler-only/front-end tests, such as glslparsertest and
asmparsertest files.  There are a lot of those, so cutting them can save
quite a bit of time when running Piglit.

Excluding glslparsertests via -x is tricky since a lot of them live way
down in the spec/... hierarchy.  It's much easier to filter them out by
checking for the GLSLParserTest class.

Essentially, gpu.tests is quick.tests minus compiler-only tests.  In the
future, we could probably remove API-only tests (though there are a much
smaller number of those and they run fairly quickly).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Add a test to ensure seamless cubemap filtering is initially disabled.

v2: Actually add the new test to all.tests.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
arb_texture_cube_map_array: sample-cube-map-array-shadow use glDrawArrays instead of piglit_draw_rect

Don't mix piglit_draw_rect and additional attribute arrays.

Signed-off-by: Fabian Bieler <fabianbieler@fastmail.fm>
Reviewed-by: Eric Anholt <eric@anholt.net>
glsl-max-varyings: Use glDrawArrays instead of piglit_draw_rect.

Don't mix piglit_draw_rect and additional attribute arrays.

Signed-off-by: Fabian Bieler <fabianbieler@fastmail.fm>
Reviewed-by: Eric Anholt <eric@anholt.net>
copyteximage: Use glDrawArrays instead of piglit_draw_rect.

Don't mix piglit_draw_rect and additional attribute arrays.

v2: Use individual functions piglit_draw_rect_tex, draw_rect_tex_3d and
    draw_rect_tex_cube_face instead of draw_rect_tex for drawing.

Signed-off-by: Fabian Bieler <fabianbieler@fastmail.fm>
Reviewed-by: Eric Anholt <eric@anholt.net>
sampler-cube-shadow: Use glDrawArrays instead of piglit_draw_rect.

Don't mix piglit_draw_rect and additional attribute arrays.

Also don't immediately quit test if not running automatically.

v2: Always call piglit_present_results, correct spelling;

Signed-off-by: Fabian Bieler <fabianbieler@fastmail.fm>
Reviewed-by: Eric Anholt <eric@anholt.net>
util: Add probe function to test for two colors.

Add piglit_probe_rect_two_rgba.
This probe functions tests that all pixels in a rectangle are one of two
specified colors.

This is useful to test that two draw operations behave identically:
To use it clear the framebuffer, enable blending and make each draw operation
paint one color channel.
Then call piglit_probe_rect_two_rgba to determine that the framebuffer is either
the clear color or the combined color of both operations.
arb_geometry_shader4/ignoreadjacent-vertices: Use piglit_probe_rect_two_rgba.

Use the newly introduced piglit_probe_rect_two_rgba to check the framebuffer.
arb_geometry_shader4: Test two sided triangles.

Draw 8 triangles on the screen like so:

    +-+-+
    |/|/|
    +-+-+
    |/|/|
    +-+-+

The left 4 triangles are front facing, the right 4 triangles are back facing.
Flip the top 4 triangles in the geometry shader (swap the first and last vertex)
and write different values to both front and back color. The result should be a
2x2 checkerboard.
gen_interpolation_tests: Support geometry shader tests.

For every non-gs test, add one test for every possible interpolation qualifier
in the geometry shader.
If a geometry shader is present, the interpolation qualifier in the vertex
shader should be ignored.

From the ARB_geometry_shader4 spec section 2.16:
"This new geometry shader pipeline stage is inserted after primitive assembly,
right before color clamping (section 2.14.6), flat shading (section 2.14.7)
and clipping (sections 2.12 and 2.14.8)."

Also add a comment in the generated test with the name of the script that
generated the test.

Note that this commit makes use of the gl_ClipDistanceIn variable, which is not
mentioned in any spec (the ARB_geometry_dhader4 spec is written against the
GLSL 1.1 spec and gl_ClipDistance was only introduced in version 1.3). Version
1.5 geometry shaders require the use of the gl_in interface block when reading
gl_ClipDistance passed from the vertex shader.
arb_geometry_shader4: Compare 2d arrays.

GLSL 1.2 allows using the equality operators (== and !=) to operate on arrays
as entire entities.

Test that they work with geometry shader 2d input arrays.
arb_geometry_shader4: Test gl_PointSize.

Draw different sized points from a geometry shader.
arb_geometry_shader4: Flat shading with undefined but ignored colors.

In this test the geometry shader outputs two flat shaded triangles and only
writes the color for the provoking vertex.

From the ARB_geometry_shader4 spec (section 8.10):
"The values of any unwritten output variables are undefined. The values of all
varying output variables and the special built-in output variables are
undefined after a call to EmitVertex()"

However, in this case the undefined values should be ignored and thus should
not affect the fragment stage.
arb_geometry_shader4: Draw more vertices than allowed.

Test a geometry shader that emits more vertices than allowed per
GEOMETRY_VERTICES_OUT.

From the ARB_geometry_shader4 spec (section 8.10):
"If a geometry shader, in one invocation, emits more vertices than the value
GEOMETRY_VERTICES_OUT_ARB, these emits may have no effect."

However the shader should execute without error and the valid vertices should
be drawn.

Test this with a geometry shader that tries to emit 14 but is only allowed to
emit 8 and one that tries to emit 510 but is only allowed to emit 256 vertices.
glsl-1.20: Access constant array of structs.

Add two tests:
Test reading from a constant array of structs.
Test reading from a constant array of structs with an array member.

This test provokes failed assertions in st/mesa: glsl_to_tgsi.