Finish NV12 support via streams.

The main functionality for NV12 texture support through EGL streams has
been added. Updates to the compiler, texture code, and stream code were
added to support binding to external D3D11 NV12 textures. An end2end test
was also added to test sampling of YUV textures and converting to RGB.
There is also a new script to convert BMP files to an NV12 texture ready
to load into D3D11 for testing purposes.

BUG=angleproject:1332

Change-Id: I098940e6f25e113dcc4fc8d22ffed4b5a16fd860
Reviewed-on: https://chromium-review.googlesource.com/339454
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Ian Ewell <ewell@google.com>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 7f6e915..6ea31bf 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -169,6 +169,15 @@
     }
 }
 
+// Most texture GL calls are not compatible with external textures, so we have a separate validation
+// function for use in the GL calls that do
+bool ValidTextureExternalTarget(const ValidationContext *context, GLenum target)
+{
+    return (target == GL_TEXTURE_EXTERNAL_OES) &&
+           (context->getExtensions().eglImageExternal ||
+            context->getExtensions().eglStreamConsumerExternal);
+}
+
 // This function differs from ValidTextureTarget in that the target must be
 // usable as the destination of a 2D operation-- so a cube face is valid, but
 // GL_TEXTURE_CUBE_MAP is not.
@@ -825,7 +834,7 @@
     }
 }
 
-bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param)
+bool ValidateTexParamParameters(gl::Context *context, GLenum target, GLenum pname, GLint param)
 {
     switch (pname)
     {
@@ -840,7 +849,9 @@
       case GL_TEXTURE_COMPARE_FUNC:
       case GL_TEXTURE_MIN_LOD:
       case GL_TEXTURE_MAX_LOD:
-        if (context->getClientVersion() < 3)
+          // ES3 texture paramters are not supported on external textures as the extension is
+          // written against ES2.
+          if (context->getClientVersion() < 3 || target == GL_TEXTURE_EXTERNAL_OES)
         {
             context->recordError(Error(GL_INVALID_ENUM));
             return false;
@@ -857,10 +868,11 @@
       case GL_TEXTURE_WRAP_R:
         switch (param)
         {
-          case GL_REPEAT:
           case GL_CLAMP_TO_EDGE:
+              return true;
+          case GL_REPEAT:
           case GL_MIRRORED_REPEAT:
-            return true;
+              return (target != GL_TEXTURE_EXTERNAL_OES);
           default:
             context->recordError(Error(GL_INVALID_ENUM));
             return false;
@@ -871,11 +883,12 @@
         {
           case GL_NEAREST:
           case GL_LINEAR:
+              return true;
           case GL_NEAREST_MIPMAP_NEAREST:
           case GL_LINEAR_MIPMAP_NEAREST:
           case GL_NEAREST_MIPMAP_LINEAR:
           case GL_LINEAR_MIPMAP_LINEAR:
-            return true;
+              return (target != GL_TEXTURE_EXTERNAL_OES);
           default:
             context->recordError(Error(GL_INVALID_ENUM));
             return false;