Don't allow multiview clear during timer query

This brings the ANGLE_multiview spec in line with WEBGL_multiview.

This also fixes the test so that the timer query extension is
requested when it is being tested.

BUG=angleproject:2062
TEST=angle_end2end_tests

Change-Id: Ibd5c117a5ae2642d26137d9ad44420d6601ba762
Reviewed-on: https://chromium-review.googlesource.com/1143283
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index 21d58fe..f1c348e 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -2554,6 +2554,7 @@
 bool ValidateClear(Context *context, GLbitfield mask)
 {
     Framebuffer *fbo = context->getGLState().getDrawFramebuffer();
+    const Extensions &extensions = context->getExtensions();
 
     if (!ValidateFramebufferComplete(context, fbo))
     {
@@ -2566,7 +2567,7 @@
         return false;
     }
 
-    if (context->getExtensions().webglCompatibility && (mask & GL_COLOR_BUFFER_BIT) != 0)
+    if (extensions.webglCompatibility && (mask & GL_COLOR_BUFFER_BIT) != 0)
     {
         constexpr GLenum validComponentTypes[] = {GL_FLOAT, GL_UNSIGNED_NORMALIZED,
                                                   GL_SIGNED_NORMALIZED};
@@ -2582,6 +2583,20 @@
         }
     }
 
+    if (extensions.multiview && extensions.disjointTimerQuery)
+    {
+        const State &state       = context->getGLState();
+        Framebuffer *framebuffer = state.getDrawFramebuffer();
+        if (framebuffer->getNumViews() > 1 && state.isQueryActive(QueryType::TimeElapsed))
+        {
+            context->handleError(InvalidOperation() << "There is an active query for target "
+                                                       "GL_TIME_ELAPSED_EXT when the number of "
+                                                       "views in the active draw framebuffer is "
+                                                       "greater than 1.");
+            return false;
+        }
+    }
+
     return true;
 }