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>
gs: Don't try to use gl_PerVertex when redeclaring fragment shader inputs.

In commit 5b1dff3 (Geometry shaders: Test gl_ClipDistance input (GLSL
1.50)) I accidentally used this syntax to redeclare the
gl_ClipDistance fragment shader input:

    in gl_PerVertex {
      float gl_ClipDistance[8];
    };

This is incorrect--gl_PerVertex is only meaningful in vertex and
geometry shaders.  In fragment shaders gl_ClipDistance isn't in any
interface block.
shader_runner: Re-use struct string_to_enum for enable_table.
shader_runner: Refactor string-to-enum lookups.

We now do all lookups associated with string_to_enum using
lookup_enum_string().

Note: this function is a little more robust than the old string
lookups--previously, we would erroneously match an initial substring
(e.g. if the table contained "GL_DEPTH_COMPONENT", it would
erroneously match "GL_DEPTH_COMPONENT16").  We used to deal with that
in an ad-hoc kludgy way (by sometimes putting trailing spaces in the
string table).  Putting proper whitespace handling in
lookup_enum_string() seems a lot safer.
shader_runner: Add the ability to set hints.
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.  Set hint
GL_FRAGMENT_SHADER_DERIVATIVE_HINT to GL_NICEST, since some
implementations may use a less accurate derivative formula by default
in order to speed up textureGrad operations.
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 that struct names may not begin with "gl_" prefix.
Test illegal usages of "gl_" prefix in interface blocks.
Test that redeclaration of gl_PerVertex must be for a subset.
Test that interface blocks cannot declare conflicting names.
Test that in general, interface blocks cannot be redeclared.
Test that the built-in gl_PerVertex interface block can be redeclared.
Test that gl_PerVertex can't be redeclared after it's been used.
Test that gl_PerVertex can't be redeclared multiple times in one shader.
Test that after redeclaration, absent members of gl_PerVertex can't be used.
Test that builtins can't be redeclared both inside and outside gl_PerVertex.
Test inter- and intra-stage gl_PerVertex matching rules.

These tests verify the following linkage rules, from GLSL 4.10:

1. If multiple shaders using members of a built-in block belonging to
the same interface are linked together in the same program, they must
all redeclare the built-in block in the same way, as described in
section 4.3.7 "Interface Blocks" for interface block matching, or a
link error will result.

2. It will also be a link error if some shaders in a program redeclare
a specific built-in interface block while another shader in that
program does not redeclare that interface block yet still uses a
member of that interface block.