Re-order the error generation for ES3 TexImage calls.

Explictly check if the internal format enum is ever valid before checking
if it is valid in combination with other parameters. Some WebGL tests
expect a certain order for generated errors.

BUG=angleproject:2009
TEST=conformance2/textures/misc/tex-input-validation

Change-Id: I31166a78d00629f8281ef53eced72575497ae448
Reviewed-on: https://chromium-review.googlesource.com/486099
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index 5274b4a..d0b5eb8 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -1892,6 +1892,12 @@
     }
 }
 
+bool ValidES3InternalFormat(GLenum internalFormat)
+{
+    const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
+    return internalFormat != GL_NONE && formatMap.find(internalFormat) != formatMap.end();
+}
+
 VertexFormat::VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn)
     : type(typeIn),
       normalized(normalizedIn),