Test that GS has access to noise functions

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
oes_matrix_get: Add basic test for GL_OES_matrix_get

This is an OpenGL ES 1.x extension that Mesa has advertised for quite
some time.  However, it appears that there is *no* code in Mesa to back
that up!

This test currently fails in all versions of Mesa.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
local build fix
piglit util: new functions piglit_program_pipeline_check_status/quiet

Equivalent to piglit_link_check_status/quiet but with program object pipeline

V4: move function in piglit-shader-gl.c (not supported on GLES*)

v5 (idr): Eliminate compiler warnings in the GLES stub
implementations.

v6 (idr): Fix typo in log message.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
sso: new test GetProgramPipelineiv

Bind various stages (including geometry and tesselation) to the pipeline
and check the result with GetProgramPipelineiv.  I take also the
opportunity to use glCreateShaderProgramv.

AMD generates an GL_INVALID_VALUE error when glActiveShaderProgram is
called with a program that isn't bound to any stage to the pipeline.
After discussions in Khronos on 9/13/2013, it was confirmed that no
error should be generated.  Essentially the program set by
glActiveShaderProgram is another stage in the pipeline (the "uniform
stage") that is just not used for rendering.

Spec quote:

    "An INVALID_VALUE error is generated if program is not the name of
    either a program or shader object.  An INVALID_OPERATION error is
    generated if program is the name of a shader object."

V4:
* split new test in a separate commit
* Merge the 2 vertex shaders with the help of the __VERSION__ macro
* Properly set shader version with asprintf

V5 (idr):
* Use 'pass = foo() && pass;' idiom instead of 'pass &= foo();'.  C's
  short-circuit evaulation rules cause these to be different.
* s/GLboolean/bool/g
* Produce no output with -auto.
* Don't add tests from future commits to CMakeLists.gl.txt yet.
* Trivial reformatting.

V6 (idr):
* Set config.supports_gl_compat_version = 20,
  config.supports_gl_core_version = 31, and remove explicit version
  checks.  Suggested by Paul.
* Add assertion in stage2bitfield default case.  Suggested by Paul.
* Use asprintf to generate version string.  Suggested by Paul.
* Unconditionally print informational messages.  Suggested by Paul.
* Minor clean-ups to tesselation and geometry shader checking.
  Suggested by Paul.
* Add comments explaining why the gl_PerVertex interface are redeclared.
  Suggested by Paul.
* Since the minimum GL version is 2.0, set default GLSL version 1.10.
  Noticed by Ian.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
sso: new test IsProgramPipeline

Check the pipeline object state creation.  glGenProgramPipelines only
reserves the names.  The object does not "exist" until it is bound.

Also take the opportunity to test negative value on
glGenProgramPipelines and glDeleteProgramPipelines.

This test fails on AMD's closed-source driver (Catalyst 13.4 on
HD5770).  The test crashes when -1 is passed to glGenProgramPipelines.
They are presumably treating the GLsizei as unsigned and generating a
lot of names.  They also return GL_TRUE from glIsProgramPipeline
before the object has been bound.

This test fails on NVIDIA's closed-source driver (unknown version on
GTX 650).  The test crashes in glGetProgramPipelineiv for a pipeline
that has never been bound.  They are presumably dereferencing a NULL
pointer in some internal data structure.  They also return GL_TRUE
from glIsProgramPipeline before the object has been bound.

V4: split the new test in a separate commit

V5 (idr):
* Use 'pass = foo() && pass;' idiom instead of 'pass &= foo();'.  C's
  short-circuit evaulation rules cause these to be different.
* s/GLboolean/bool/g
* Produce no output with -auto.
* Add test to CMakeLists.gl.txt.
* Trivial reformatting.

V6 (idr):
* Set config.supports_gl_compat_version = 20,
  config.supports_gl_core_version = 31, and remove explicit version
  checks.  Suggested by Paul.
* Use piglit_reset_gl_error instead of open coding it.  Noticed by Ian.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
sso: Verify UseProgramStages of a non-separable program generates an error

Also verify the default state of GL_SEPARABLE_PROGRAM.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
update EXT_transform_feedback error detection

program pipeline add new INVALID_OPERATION (spec chapter 13.2.2)

Note: FGLRX don't report any of the expected errors...

V4:
* merge the separate vertex shader
* use asprintf to set the version (avoid bug in FGLRX)

V5 (idr):
* Trivial reformatting.

V6 (idr):
* Move the comment about the AMD work around to the location of the work
  around.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
sso: new test ValidateProgramPipeline

Catalyst status: Part 11 & 12 failed

V4:
* Use standard piglit_report_subtest_result (with basic test number)
* use standard bool versus GLBoolean
* Merge VS shader with the help of __VERSION__
* asprintf shader with a common GLSL version

V5 (idr):
* Use 'pass = foo() && pass;' idiom instead of 'pass &= foo();'.  C's
  short-circuit evaulation rules cause these to be different.
* #extension is only necessary to use layout qualifiers, so remove it.
* Produce no output with -auto.
* Use descriptive names for subtests.
* Trivial reformatting.
* Refactor (and reorder) test bodies into the
  build_and_validate_pipeline function.

V6 (idr):

* Modify last subtest to relink the vertex shader instead of the
  fragment shader.  This allows the entire test to work with core
  profile.  Enable config.supports_gl_core_version = 31.  Suggested by
  Paul.
* Fix geometry shader checks.  The shaders are all written to use GLSL
  1.50 style geometry shaders, so only enable GS when OpenGL 3.2 is
  available, not when GL_ARB_geometry_shader4 is available.  Suggested
  by Paul.
* Various other reformatting and code tweaks suggested by Paul.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
sso: Test all of the ProgramUniform entry points

This is a nearly exhaustive test of all the glProgramUniform functions
added by GL_ARB_separate_shader_objects.

For every entrypoint, a shader using a uniform of the correct type is
created using glCreateShaderProgramv.  The uniform is then set and
queried (using glGetUniform).  The test passes if the correct data is
returned and no GL errors are generated.

The following aspects of these interfaces are not tested by this test:

    - Uniform arrays set by glProgramUniform*v or by
      glProgramUniformMatrix*v with count > 1.

    - Transpose matrices set by glProgramUniformMatrix*v with transpose
      set to GL_TRUE.

v2: Make the double tests use doubles (instead of unsigned integers).
Copy-and-paste error noticed by Paul.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
Revert "local build fix"

This reverts commit 271d0651df63d29ee263c9de0df6b683f6fdbc3f.

I didn't intend to push this.  Oops.
glsl-1.30: Test interpolation qualifiers on built-in variables

Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:

    "If gl_Color is redeclared with an interpolation qualifier, then
    gl_FrontColor and gl_BackColor (if they are written to) must also be
    redeclared with the same interpolation qualifier, and vice versa. If
    gl_SecondaryColor is redeclared with an interpolation qualifier,
    then gl_FrontSecondaryColor and gl_BackSecondaryColor (if they are
    written to) must also be redeclared with the same interpolation
    qualifier, and vice versa. This qualifier matching on predeclared
    variables is only required for variables that are statically used
    within the shaders in a program."

This adds five sets of tests from a single generator script:

    - Set an interpolation qualifier, possibly the default, for one of
      gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor, or
      gl_BackSecondaryColor in the vertex shader, and set a different
      interpolation qualifier, possibly the default, for the matching
      gl_Color or gl_SecondaryColor in the fragment shader.  This should
      fail to link.

    - Set a non-default interpolation qualifier for one of
      gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor, or
      gl_BackSecondaryColor in the vertex shader, and have no
      redeclaration in the fragment shader.  In the fragment shader,
      neither gl_Color nor gl_SecondaryColor is used.  This should
      successfully link.

    - Set a non-default interpolation qualifier for one of gl_Color or
      gl_SecondaryColor in the fragment shader, and have no
      redeclaration in the vertex shader.  In the vertex shader, none of
      the built-in color variables are used.  This should successfully
      link.

    - Set an interpolation qualifier, possibly the default, for one of
      gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor, or
      gl_BackSecondaryColor in the vertex shader, and set a different
      interpolation qualifier, possibly the default, for the matching
      gl_Color or gl_SecondaryColor in the fragment shader.  Neither
      stage uses any of the color variables.  This should successfully
      to link.

    - Set conflicting interpolation qualifiers for gl_FrontColor /
      gl_BackColor or gl_FrontSecondaryColor / gl_BackSecondaryColor in
      the vertex shader, and set a matching interpolation qualifier on
      gl_Color or gl_SecondaryColor in the fragment shader for one of
      the vertex shader built-in varaibles.  This should fail to link.

On Mesa, all of the tests that expect linking failures fail.  Basically,
Mesa's linker accepts everything.

NVIDIA (304.64 on GTX 260) fails the same set of tests.

v2: Use Python lists instead of "set literal" syntax (Python 2.7+ only).
Change the names of several maps to include the suffix _map.  Rename
some additional varibles that had a misleading "front" or "back" in the
name.  All changes suggested by Paul.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=47755
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl-1.50: Test illegal uses of unsized arrays in interface blocks.

These tests verify that unsized arrays appearing inside interface
blocks are subject to the same restrictions as unsized arrays
appearing outside interface blocks (e.g. they can't be used in bulk
assignment, they don't support .length(), and they can't be accessed
using a non-constant index).

Since it's likely that these restrictions are enforced by the same
code as for unsized arrays appearing outside of interface blocks,
these are just a few touch tests; we don't exhaustively test all
possible types of access in every shader type.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Test unsized arrays in interface blocks

These tests verify that unsized arrays appearing inside interface
blocks obey the same rules as unsized arrays appearing outside
interface blocks.  Namely, their size is inferred from the largest
constant integer index used to access them across all compilation
units for the same shader stage, and this inferred size is used to
validate that interface blocks are properly matched between one shader
stage and the next.
Test accuracy of dFdx and dFdy functions.

Mesa/i965 currently (as of commit 1cc3b90) has an inaccurate
implementation of dFdy() which produces the same results for every
pixel in an aligned 2x2 block.  This piglit test exposes the
inaccuracy.

v2: Use an error threshold of 1.0e-3 for both tests.
!UPSTREAM: Interface block redeclaration tests

TODO:
- Add more tests

- Split into a patch for the GLSL 4.10 redeclaration rules and a patch
  for other GLSL 1.50 issues (e.g. disallowing a variable inside an
  unnamed interface block to match the name of a previously declared
  global)

- Validate using NVIDIA proprietary driver