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 that all vertex shader inputs are enumerated by GetActiveAttrib().
This includes built-ins such as gl_InstanceID and gl_VertexID.

v2: Restructure test to check attrib names on an individual basis

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
egl_khr_create_context: Fix tests for invalid flags (v2)

According to version 15 of the EGL_KHR_create_context spec,
EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR is a valid flag for OpenGL ES contexts.
But the test "EGL_KHR_create_context/invalid flag GLES" verifies that it
is an *invalid* flag.

v2: Use smarter loop that can correctly handle discontinuities in
    the invalid_flag mask.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util/egl: Add piglit_egl_bind_api()

This is a wrapper for eglBindAPI() that does error-checking.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
egl_khr_create_context: Test the debug flag (v2)

Test eglCreateContext with with EGL_CONTEXT_OPENGL_BIT_KHR set for GL,
GLES1, GLES2, and GLES3.  If context creation succeeds, then verify the
context is really a debug context by verifying GL_CONTEXT_FLAGS contains
GL_CONTEXT_FLAG_DEBUG_BIT.  If context creation fails, then verify that
EGL_BAD_MATCH is emitted.

v2:
  - Inline the printf format string (Matt).
  - Really create GLES2 and GLES3 contexts. In v1, on attempts to create
    GLES2 and GLES3 contexts, a GLES1 context was created instead.
  - Piglit lacks dispatch for ES1. So, for ES1 test, initialize dispatch
    to ES2.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69624
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
ARB_texture_gather: add initial execution test

This test exercises combinations of:
- Shader stage vs/fs
- Offsetting
- Component count, up to implementation-defined limit
- Swizzling
- Unsigned normalized, float, int, unsigned int component types
- 2D/2DArray/Cube/CubeArray samplers

The test works by numbering the texels, and ensuring that the four
texels sampled by textureGather*() are those we expect.

Not exercised yet:
- Other interesting internalformats [DEPTH_COMPONENT, etc]
- Addressing modes other than WRAP.
- Use in Geometry Shader. I'd like to pick this up later, as mesa's
  GS support matures.

V2: - Use textureSize rather than hardcoding size in shader;
    - Use piglit_build_simple_program
    - Whitespace tidyups
    - Convert swizzle to enum
    - More component types, for all gsampler2D variants.

V3: - More whitespace
V4: - allow explicit 'unorm' component type; rework usage
    - Support all required sampler types.
    - Refactor setup

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
shader_runner: add ability to specify GL_TEXTURE_BASE_LEVEL

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
shader_runner: add ability to control red swizzle texparameter

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>