ES31: Add link validation on geometry shader varyings

This patch adds the link validation on geometry shader varyings.

According to SPEC, geometry shader inputs should not be treated
as arrays for the purpose of interface matching.

This patch also moves the checks on fragment input bindings into
a single function.

BUG=angleproject:1941
TEST=angle_end2end_tests
     dEQP-GLES31.functional.shaders.linkage.es31.geometry.varying.*

Change-Id: Ib3ca64e28683e9688edc9432d43ff5a70c86117e
Reviewed-on: https://chromium-review.googlesource.com/929866
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/tests/gl_tests/GeometryShaderTest.cpp b/src/tests/gl_tests/GeometryShaderTest.cpp
index 072492a..93afb94 100644
--- a/src/tests/gl_tests/GeometryShaderTest.cpp
+++ b/src/tests/gl_tests/GeometryShaderTest.cpp
@@ -268,6 +268,54 @@
     ASSERT_GL_NO_ERROR();
 }
 
+// Verify that an link error occurs when the vertex shader has an array output and there is a
+// geometry shader in the program.
+TEST_P(GeometryShaderTest, VertexShaderArrayOutput)
+{
+    ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_geometry_shader"));
+
+    const std::string &vertexShader =
+        R"(#version 310 es
+        in vec4 vertex_in;
+        out vec4 vertex_out[3];
+        void main()
+        {
+            gl_Position = vertex_in;
+            vertex_out[0] = vec4(1.0, 0.0, 0.0, 1.0);
+            vertex_out[1] = vec4(0.0, 1.0, 0.0, 1.0);
+            vertex_out[2] = vec4(0.0, 0.0, 1.0, 1.0);
+        })";
+
+    const std::string &geometryShader =
+        R"(#version 310 es
+        #extension GL_EXT_geometry_shader : require
+        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];
+            EmitVertex();
+        })";
+
+    const std::string &fragmentShader =
+        R"(#version 310 es
+        precision mediump float;
+        in vec4 geometry_color;
+        layout (location = 0) out vec4 output_color;
+        void main()
+        {
+            output_color = geometry_color;
+        })";
+
+    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());
 }