ES31: Add link validation on geometry shader itself

This patch intends to support program link validation on geometry
shader itself. A link error should occur when linking a program with
a geometry shader that lacks input primitive or output primitive or
the declaration of 'max_vertices'.

This patch also adds the support of linking a program with geometry
shader in angle_end2end_tests.

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

Change-Id: I25fb08514753102f5dd3ab86211c05d2ca4fd185
Reviewed-on: https://chromium-review.googlesource.com/898842
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/gl/ProgramGL.cpp b/src/libANGLE/renderer/gl/ProgramGL.cpp
index fc4aebb..86d17cb 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -178,10 +178,16 @@
 
         const ShaderGL *vertexShaderGL   = GetImplAs<ShaderGL>(mState.getAttachedVertexShader());
         const ShaderGL *fragmentShaderGL = GetImplAs<ShaderGL>(mState.getAttachedFragmentShader());
+        const ShaderGL *geometryShaderGL =
+            rx::SafeGetImplAs<ShaderGL, gl::Shader>(mState.getAttachedGeometryShader());
 
         // Attach the shaders
         mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID());
         mFunctions->attachShader(mProgramID, fragmentShaderGL->getShaderID());
+        if (geometryShaderGL)
+        {
+            mFunctions->attachShader(mProgramID, geometryShaderGL->getShaderID());
+        }
 
         // Bind attribute locations to match the GL layer.
         for (const sh::Attribute &attribute : mState.getAttributes())
@@ -201,6 +207,10 @@
         // Detach the shaders
         mFunctions->detachShader(mProgramID, vertexShaderGL->getShaderID());
         mFunctions->detachShader(mProgramID, fragmentShaderGL->getShaderID());
+        if (geometryShaderGL)
+        {
+            mFunctions->detachShader(mProgramID, geometryShaderGL->getShaderID());
+        }
     }
 
     // Verify the link