ES31: copy to a texture with RGB9_E5 internalformat is invalid.

BUG=angleproject:2378
TEST=dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.copytexsubimage2d_texture_internalformat

Change-Id: I4ad0ec6636c0312a3ecfeb47df3297e4bf399c35
Reviewed-on: https://chromium-review.googlesource.com/938328
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 2fd2961..f132e69 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -820,6 +820,14 @@
 
     const FramebufferAttachment *source = framebuffer->getReadColorbuffer();
 
+    // According to ES 3.x spec, if the internalformat of the texture
+    // is RGB9_E5 and copy to such a texture, generate INVALID_OPERATION.
+    if (textureFormat.info->internalFormat == GL_RGB9_E5)
+    {
+        context->handleError(InvalidOperation());
+        return false;
+    }
+
     if (isSubImage)
     {
         if (!IsValidES3CopyTexImageCombination(*textureFormat.info, *source->getFormat().info,