WebGL: Validate texture copying feedback loops.

This adds basic validation for catching CopyTex{Sub}Image calls
whose source and destination textures overlap. It does not yet
implement full support for ES3 types (3D textures, array textures).

BUG=angleproject:1685

Change-Id: I83e7b1998df5575057fed8f99f7ee9970fb38df0
Reviewed-on: https://chromium-review.googlesource.com/425491
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index ad604c4..106923c 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -3124,6 +3124,19 @@
     {
         *textureFormatOut = texture->getFormat(target, level);
     }
+
+    // Detect texture copying feedback loops for WebGL.
+    if (context->getExtensions().webglCompatibility)
+    {
+        if (readFramebuffer->formsCopyingFeedbackLoopWith(texture->id(), level))
+        {
+            context->handleError(Error(GL_INVALID_OPERATION,
+                                       "Texture copying feedback loop formed between Framebuffer "
+                                       "and specified Texture level."));
+            return false;
+        }
+    }
+
     return true;
 }