ES31: Add link validations on geometry shader uniforms

This patch adds the link validations on the uniforms defined in a
geometry shader.

1. Validate if there is any link mismatch between a geometry shader
   uniform and a uniform defined in another shader in the current
   graphics pipeline.
2. Validate if the number of images, samplers or atomic counters in
   a geometry shader exceeds the related resource limit.
3. Validate if there is name contradiction between a geometry shader
   uniform and a vertex shader attribute.

BUG=angleproject:1941
TEST=dEQP-GLES31.functional.shaders.linkage.es31.geometry.uniform.*
     dEQP-GLES31.functional.geometry_shading.basic.*
     dEQP-GLES31.functional.geometry_shading.conversion.*
     dEQP-GLES31.functional.geometry_shading.emit.*
     dEQP-GLES31.functional.geometry_shading.varying.*
     dEQP-GLES31.functional.geometry_shading.instanced.geometry_*
     dEQP-GLES31.functional.geometry_shading.instanced.invocation_output_*
     dEQP-GLES31.functional.geometry_shading.instanced.draw_*

Change-Id: I365aee624a3a79658c3e4c7487a586cf9532b529
Reviewed-on: https://chromium-review.googlesource.com/939264
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/tests/gl_tests/GeometryShaderTest.cpp b/src/tests/gl_tests/GeometryShaderTest.cpp
index 93afb94..eefd653 100644
--- a/src/tests/gl_tests/GeometryShaderTest.cpp
+++ b/src/tests/gl_tests/GeometryShaderTest.cpp
@@ -316,6 +316,55 @@
     EXPECT_GL_NO_ERROR();
 }
 
+// Verify that an link error occurs when the definition of a unform in fragment shader is different
+// from those in a geometry shader.
+TEST_P(GeometryShaderTest, UniformMismatchBetweenGeometryAndFragmentShader)
+{
+    ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_geometry_shader"));
+
+    const std::string &vertexShader =
+        R"(#version 310 es
+        uniform highp vec4 uniform_value_vert;
+        in vec4 vertex_in;
+        out vec4 vertex_out;
+        void main()
+        {
+            gl_Position = vertex_in;
+            vertex_out = uniform_value_vert;
+        })";
+
+    const std::string &geometryShader =
+        R"(#version 310 es
+        #extension GL_EXT_geometry_shader : require
+        uniform vec4 uniform_value;
+        layout (invocations = 3, triangles) in;
+        layout (points, max_vertices = 3) out;
+        in vec4 vertex_out[];
+        out vec4 geometry_color;
+        void main()
+        {
+            gl_Position = gl_in[0].gl_Position;
+            geometry_color = vertex_out[0] + uniform_value;
+            EmitVertex();
+        })";
+
+    const std::string &fragmentShader =
+        R"(#version 310 es
+        precision highp float;
+        uniform float uniform_value;
+        in vec4 geometry_color;
+        layout (location = 0) out vec4 output_color;
+        void main()
+        {
+            output_color = vec4(geometry_color.rgb, uniform_value);
+        })";
+
+    GLuint program = CompileProgramWithGS(vertexShader, geometryShader, fragmentShader);
+    EXPECT_EQ(0u, program);
+
+    EXPECT_GL_NO_ERROR();
+}
+
 ANGLE_INSTANTIATE_TEST(GeometryShaderTestES3, ES3_OPENGL(), ES3_OPENGLES(), ES3_D3D11());
 ANGLE_INSTANTIATE_TEST(GeometryShaderTest, ES31_OPENGL(), ES31_OPENGLES(), ES31_D3D11());
 }