Validation layer fixes for compressedtexsubimage* dEQP tests

* Change order of validation in ValidateCompressedTexSubImage3D
to get the errors in the same order as the dEQP tests are
expecting them.
* ES 3.1: Section 8.7, page 169: If the internal format is ETC2/EAC,
the target must be a GL_TEXTURE_2D_ARRAY.
* ES 3.1: Section 8.7, page 171: For sub textures, ET2/EAC formats
also requires exact size to be validated.

Bug: angleproject:2327

Change-Id: Ib049c70a52ed5683885a73fb06503898a85786d1
Reviewed-on: https://chromium-review.googlesource.com/897726
Commit-Queue: Luc Ferron <lucferron@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 25a6433..2e0c02f 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -529,6 +529,13 @@
         return false;
     }
 
+    if (IsETC2EACFormat(format) && target != GL_TEXTURE_2D_ARRAY)
+    {
+        // ES 3.1, Section 8.7, page 169.
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), InternalFormatRequiresTexture2DArray);
+        return false;
+    }
+
     return ValidateES3TexImageParametersBase(context, target, level, internalformat, isCompressed,
                                              isSubImage, xoffset, yoffset, zoffset, width, height,
                                              depth, border, format, type, bufSize, pixels);
@@ -2026,16 +2033,22 @@
         return false;
     }
 
+    if (!ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, xoffset,
+                                         yoffset, zoffset, width, height, depth, 0, format, GL_NONE,
+                                         -1, data))
+    {
+        return false;
+    }
+
     if (!data)
     {
         context->handleError(InvalidValue());
         return false;
     }
 
-    return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, xoffset,
-                                           yoffset, zoffset, width, height, depth, 0, format,
-                                           GL_NONE, -1, data);
+    return true;
 }
+
 bool ValidateCompressedTexSubImage3DRobustANGLE(Context *context,
                                                 GLenum target,
                                                 GLint level,