port ttexrect.cpp to piglit from glean

This ported test goes into tests/spec/arb_texture_rectangle. It
tests the ARB_texture_rectangle extension.

Create a 255x127 texture of varying colors and bind it as a
GL_ARB_texture_recangle target.  Draw that rectangle to the window, and
check that the texture was drawn correctly.  The common failure to be
caught with this test is not adjusting the non-normalized coordinates on
hardware that expects normalized coordinates.

To all.tests, add new texrect_simple_arb_texrect

v2: add PIGLIT_GL_VISUAL_DOUBLE to the window_visual, move various
setup bits to piglit_init and add forgotten all.tests change.
v3: use piglit_present_results, and piglit_probe_image_rgb
v4: use piglit_draw_rect_tex, piglit_ortho_projection and minor
clean ups.

Signed-off-by: Tom Gall <tom.gall@linaro.org>

Reviewed-by: Brian Paul <brianp@vmware.com>
rm tests/glean/ttexrect.*

Remove ttexrect.* from glean as the previous patch ports the test
to piglit.

Remove texRect from all.tests.

Signed-off-by: Tom Gall <tom.gall@linaro.org>

Reviewed-by: Brian Paul <brianp@vmware.com>
Remove BindBufferRange out-of-range tests.

In the documentation for BindBufferRange, OpenGL specs from 3.0
through 4.1 contain this language:

    "The error INVALID_VALUE is generated if size is less than or
    equal to zero or if offset + size is greater than the value of
    BUFFER_SIZE."

This text was dropped from OpenGL 4.2, and it does not appear in the
GLES 3.0 spec.

Presumably the reason for the change is because come clients change
the size of the buffer after calling BindBufferRange.  Implementations
shouldn't generate an error at the time of the BindBufferRange call
just because the old size of the buffer was too small, when the buffer
is about to be resized.

Since this is a deliberate relaxation of error conditions in order to
allow clients to work, it seems sensible to allow implementations to
apply this change even if the GL version is less than 4.2.  This patch
eliminates the checks that would have required the error condition to
be flagged.

See associated Mesa patch:

    mesa: Don't check (offset + size <= bufObj->Size) in BindBufferRange.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>

v2: Replace the removed checks with a comment noting that we're
explicitly not testing this language.
texture-integer-glsl130: fix wrong expected G/B values for L/LA/I formats

The tests expects the green and blue values to be the same as the luminance
(or intensity) value but it should be zero.
(Mesa used to do the former for readpixels probably due to complex wording
in earlier gl specs but this was considered an error and subsequently changed
in ad897fff7730298c21289768d9b1b55f3d166ac5.)

Tested-by: Brian Paul <brianp@vmware.com>
getteximage-formats: test GetTexImage after rendering to textures

This tests whether our GetTexImage doesn't actually rely on TexImage being
called first. In this test, TexImage is not used to store data.

Reviewed-by: Brian Paul <brianp@vmware.com>
Test default precision qualifiers for samplers in GLSL ES.

Reviewed-by: Eric Anholt <eric@anholt.net>
GLES3: test that non-flat varying structs cannot contain ints.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Modify tests for error checking on "flat" keyword to match updated specs.

All of the GLSL specs from GLSL 1.30 (and GLSL ES 3.00) onward contain
language requiring certain integer variables to be declared with the
"flat" keyword, but they differ in exactly *when* the rule is
enforced:

(a) GLSL 1.30 and 1.40 say that vertex shader outputs having integral
type must be declared as "flat".  There is no restriction on fragment
shader inputs.

(b) GLSL 1.50 through 4.30 say that fragment shader inputs having
integral type must be declared as "flat".  There is no restriction on
vertex shader outputs.

(c) GLSL ES 3.00 says that both vertex shader outputs and fragment
shader inputs having integral type must be declared as "flat".

Previously, Piglit simply checked for behaviour (a).  This patch makes
it check for behaviour (b) in desktop GL and behaviour (c) in GLES.

Rationale: once geometry shader support is included, (b) is the only
sensible choice, because it requires "flat" in just the situations
where it matters.  Since many implementations extend geometry shader
support back before GLSL 1.50 (via ARB_geometry_shader4), it seems
sensible to regard the difference between (a) and (b) as a bug fix
rather than a deliberate behavioural difference, and therefore test
for behaviour (b) even in GLSL 1.30.

Some discussion about this has already happened on the Mesa-dev list.
See:

http://lists.freedesktop.org/archives/mesa-dev/2013-February/034199.html

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
cl: Add % to the list of illegal characters in test names

% was being interpreted as a format string in some cases
gles-2.0: Check illegality of attaching multiple shader objects of same type

From the OpenGL ES 2.0 spec, Section 2.10.3 Program Objects:

   Multiple shader objects of the same type may not be attached to
   a single program object. [...] The error INVALID_OPERATION is generated
   if [...] another shader object of the same type as shader is already
   attached to program.

This test checks that GL_INVALID_OPERATION is generated.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Anunj Phogat <anuj.phogat@gmail.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
arb_texture_buffer_range: add initial tests (dlist, errors, ranges)

v2:
errors: Test negative size and positive non-aligned offset.
ranges: Use macro to generate main function, fix issues with
fragment shader.

Reviewed-by: Eric Anholt <eric@anholt.net>
shader_runner and glslparsertest: choose GL version more accurately.

Previously, both shader_runner and glslparsertest contained switch
statements that attempted to choose a GL version for testing based on
a GLSL version requirement, and those switch statements didn't choose
a GL version very accurately (for example, they converted GLSL version
1.50 to GL version 3.1, which doesn't work).

This patch replaces the switch statements with a single common
function (in piglit-util-gl-common) that does the right thing.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
shader_runner: Remove unimplemented geometry_program vestiges.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
shader_runner: Add support for testing geometry shaders.

Note that there are two slightly different variants of geometry
shaders: those supported by GLSL 1.50 and those supported by
ARB_geometry_shader4.  A principal difference between these two
variants is in how geometry shader layout parameters are specified
(i.e. input and output primitive types, max number of output
vertices).  When using GLSL 1.50 style geometry shaders, these layout
parameters are specified in the shader source.  When using
ARB_geometry_shader4 style geometry shaders, these layout parameters
are specified by calling glProgramParameteriARB() prior to linking.

In order to support both variants, this patch allows an optional
"[geometry layout]" section to shader_runner test files.  For example
the following [geometry layout] section:

    [geometry layout]
    input type GL_POINTS
    output type GL_LINE_STRIP
    vertices out 3

Causes shader_runner to make these calls prior to linking:

    glProgramParameteriARB(prog, GL_GEOMETRY_INPUT_TYPE_ARB,
                           GL_POINTS);
    glProgramParameteriARB(prog, GL_GEOMETRY_OUTPUT_TYPE_ARB,
                           GL_LINE_STRIP);
    glProgramParameteriARB(prog, GL_GEOMETRY_VERTICES_OUT_ARB, 3);

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
glslparsertest: Add support for testing geometry shaders.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Basic geometry shader sanity tests.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Add geometry testing to code-generated tests.

This patch adds geometry shader variants to the code-generated
built-in function tests produced by gen_builtin_uniform_tests.py and
gen_constant_array_size_tests.py.

Note that there are two ways in which an implementation may expose
geometry shader support: via GLSL 1.50 or via ARB_geometry_shader4.
After some discussion on IRC, I've provisionally decided to write most
of the geometry shader tests using ARB_geometry_shader4, and then only
supply GLSL-1.50-based tests for basic santy testing and to cover the
cases where GLSL 1.50 and ARB_geometry_shader4 differ.

Rationale: (a) Mesa is likely to implement ARB_geometry_shader4
support before GLSL 1.50 support (since Bryan Cain already has some
work-in-progress geometry shader patches that use
ARB_geometry_shader4).  (b) there are likely to be some
implementations that support geometry shaders but not GLSL 1.50
(e.g. Mesa softpipe, or i965 Gen5); writing most of the tests for
ARB_geometry_shader4 ensures that those implementations are
well-covered.

Accordingly, these code-generated tests are written entirely using
ARB_geometry_shader4.

Reviewed-by: Eric Anholt <eric@anholt.net>
GLSL ES: Verify that fragment shaders have no default float precision.

Tested on the nVidia proprietary driver for Linux.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60737

Reviewed-by: Eric Anholt <eric@anholt.net>
glsl-es-1.00: Move contents of glsl-1.00 to glsl-es-1.00

Move contents of glsl-1.00 to the glsl-es-1.00 directory.

Remove a few blank lines at the end of 4 tests so that git is happy.

Last fix up all.tests so that all shader and glslparser tests for
glsl-es-1.00 are listed and referenced in the new directory.

V2: patch squashed and generated with --find-renames

Signed-off-by: Tom Gall <tom.gall@linaro.org>

V3 (Paul Berry <stereotype441@gmail.com>): Add missing initialization
of spec['glsl-es-1.00']['execution'] to all.tests.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
shader_runner: remove explicit #version directive from generated_tests.

It is instead inserted by shader_runner based on the GLSL requirement.

Tested with all.tests - glean: same number of passes.

Signed-off-by: Stuart Abercrombie <sabercrombie@chromium.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>