Disallow timer queries with multi-view draw framebuffers

According to the ANGLE_multiview spec Draw* commands should generate
an INVALID_OPERATION error if there is an active query object for
target TIME_ELAPSED_EXT and the number of views in the active draw
framebuffer is greater than 1.

BUG=angleproject:2062
TEST=angle_end2end_tests

Change-Id: I8a4434784ecec753a39c5ef82fa3ee46255a0851
Reviewed-on: https://chromium-review.googlesource.com/593315
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Martin Radev <mradev@nvidia.com>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index c3b7d4c..f3ee493 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -2800,8 +2800,8 @@
     // Note: these separate values are not supported in WebGL, due to D3D's limitations. See
     // Section 6.10 of the WebGL 1.0 spec.
     Framebuffer *framebuffer = state.getDrawFramebuffer();
-    if (context->getLimitations().noSeparateStencilRefsAndMasks ||
-        context->getExtensions().webglCompatibility)
+    const Extensions &extensions = context->getExtensions();
+    if (context->getLimitations().noSeparateStencilRefsAndMasks || extensions.webglCompatibility)
     {
         const FramebufferAttachment *dsAttachment =
             framebuffer->getStencilOrDepthStencilAttachment();
@@ -2818,7 +2818,7 @@
 
         if (differentRefs || differentWritemasks || differentMasks)
         {
-            if (!context->getExtensions().webglCompatibility)
+            if (!extensions.webglCompatibility)
             {
                 ERR() << "This ANGLE implementation does not support separate front/back stencil "
                          "writemasks, reference values, or stencil mask values.";
@@ -2847,7 +2847,7 @@
         return false;
     }
 
-    if (context->getExtensions().multiview)
+    if (extensions.multiview)
     {
         const int programNumViews     = program->getNumViews();
         const int framebufferNumViews = framebuffer->getNumViews();
@@ -2868,6 +2868,16 @@
                                     "framebuffer is greater than 1.");
             return false;
         }
+
+        if (extensions.disjointTimerQuery && framebufferNumViews > 1 &&
+            state.isQueryActive(GL_TIME_ELAPSED_EXT))
+        {
+            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;
+        }
     }
 
     // Uniform buffer validation
@@ -2906,7 +2916,7 @@
     }
 
     // Do some additonal WebGL-specific validation
-    if (context->getExtensions().webglCompatibility)
+    if (extensions.webglCompatibility)
     {
         // Detect rendering feedback loops for WebGL.
         if (framebuffer->formsRenderingFeedbackLoopWith(state))