Make the NPOT extension requestable. Fix NPOT validation in CopyTexImage.

BUG=angleproject:1523
BUG=668223
TEST=conformance/more/functions/copyTexImage2DBadArgs.html

Change-Id: I5fbf4f99fa941c356ecb57d67dd47a33741ce189
Reviewed-on: https://chromium-review.googlesource.com/418944
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index b073267..1095017 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -1494,7 +1494,7 @@
     return level <= gl::log2(static_cast<int>(maxDimension));
 }
 
-bool ValidImageSizeParameters(const Context *context,
+bool ValidImageSizeParameters(const ValidationContext *context,
                               GLenum target,
                               GLint level,
                               GLsizei width,
@@ -1509,7 +1509,9 @@
 
     // TexSubImage parameters can be NPOT without textureNPOT extension,
     // as long as the destination texture is POT.
-    if (!isSubImage && !context->getExtensions().textureNPOT &&
+    bool hasNPOTSupport =
+        context->getExtensions().textureNPOT && context->getClientVersion() >= Version(3, 0);
+    if (!isSubImage && !hasNPOTSupport &&
         (level != 0 && (!gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth))))
     {
         return false;