Generate error on program-framebuffer num views mismatch

According to the ANGLE_multiview spec Draw* commands should generate
an INVALID_OPERATION error if the program uses the multiview extension
and the number of views in the active draw framebuffer and active
program differs. The patch addresses this by extending the base draw
call validation.

BUG=angleproject:2062
TEST=angle_end2end_tests

Change-Id: I369070beb5ccb17211dbe61ebec40bfcbcf5bc4e
Reviewed-on: https://chromium-review.googlesource.com/586605
Commit-Queue: Martin Radev <mradev@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/Shader.cpp b/src/libANGLE/Shader.cpp
index e477df0..7de8c59 100644
--- a/src/libANGLE/Shader.cpp
+++ b/src/libANGLE/Shader.cpp
@@ -78,6 +78,7 @@
     : mLabel(),
       mShaderType(shaderType),
       mShaderVersion(100),
+      mNumViews(-1),
       mCompileStatus(CompileStatus::NOT_COMPILED)
 {
     mLocalSize.fill(-1);
@@ -272,6 +273,7 @@
     mState.mInterfaceBlocks.clear();
     mState.mActiveAttributes.clear();
     mState.mActiveOutputVariables.clear();
+    mState.mNumViews = -1;
 
     mState.mCompileStatus = CompileStatus::COMPILE_REQUESTED;
     mBoundCompiler.set(context, context->getCompiler());
@@ -370,7 +372,11 @@
         }
         case GL_VERTEX_SHADER:
         {
-            mState.mActiveAttributes = GetActiveShaderVariables(sh::GetAttributes(compilerHandle));
+            {
+                mState.mActiveAttributes =
+                    GetActiveShaderVariables(sh::GetAttributes(compilerHandle));
+                mState.mNumViews = sh::GetVertexShaderNumViews(compilerHandle);
+            }
             break;
         }
         case GL_FRAGMENT_SHADER:
@@ -469,6 +475,12 @@
     return mState.mLocalSize;
 }
 
+int Shader::getNumViews(const Context *context)
+{
+    resolveCompile(context);
+    return mState.mNumViews;
+}
+
 const std::string &Shader::getCompilerResourcesString() const
 {
     ASSERT(mBoundCompiler.get());