Allow 32-bit float formats in ES2 CopyTexSubImage.

These corner case formats can come about from using floating
point textures and trying to copy between them. There currently
isn't a good alternative in WebGL 1 for copies.

BUG=angle:850

Change-Id: I3dc29e42b5ec7dcf071185bc09c6b3e9e3cb3207
Reviewed-on: https://chromium-review.googlesource.com/241048
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index e5c3da5..9eece1b 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -411,7 +411,8 @@
 
     gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
     GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
-    GLenum textureFormat = gl::GetInternalFormatInfo(textureInternalFormat).format;
+    const auto &internalFormatInfo = gl::GetInternalFormatInfo(textureInternalFormat);
+    GLenum textureFormat = internalFormatInfo.format;
 
     // [OpenGL ES 2.0.24] table 3.9
     if (isSubImage)
@@ -448,7 +449,11 @@
                   colorbufferFormat != GL_RGB8_OES &&
                   colorbufferFormat != GL_RGBA4 &&
                   colorbufferFormat != GL_RGB5_A1 &&
-                  colorbufferFormat != GL_RGBA8_OES)
+                  colorbufferFormat != GL_RGBA8_OES &&
+                  colorbufferFormat != GL_R32F &&
+                  colorbufferFormat != GL_RG32F &&
+                  colorbufferFormat != GL_RGB32F &&
+                  colorbufferFormat != GL_RGBA32F)
               {
                   context->recordError(Error(GL_INVALID_OPERATION));
                   return false;
@@ -460,7 +465,10 @@
                   colorbufferFormat != GL_RGB8_OES &&
                   colorbufferFormat != GL_RGBA4 &&
                   colorbufferFormat != GL_RGB5_A1 &&
-                  colorbufferFormat != GL_RGBA8_OES)
+                  colorbufferFormat != GL_RGBA8_OES &&
+                  colorbufferFormat != GL_RG32F &&
+                  colorbufferFormat != GL_RGB32F &&
+                  colorbufferFormat != GL_RGBA32F)
               {
                   context->recordError(Error(GL_INVALID_OPERATION));
                   return false;
@@ -471,7 +479,9 @@
                 colorbufferFormat != GL_RGB8_OES &&
                 colorbufferFormat != GL_RGBA4 &&
                 colorbufferFormat != GL_RGB5_A1 &&
-                colorbufferFormat != GL_RGBA8_OES)
+                colorbufferFormat != GL_RGBA8_OES &&
+                colorbufferFormat != GL_RGB32F &&
+                colorbufferFormat != GL_RGBA32F)
             {
                 context->recordError(Error(GL_INVALID_OPERATION));
                 return false;
@@ -481,7 +491,8 @@
           case GL_RGBA:
             if (colorbufferFormat != GL_RGBA4 &&
                 colorbufferFormat != GL_RGB5_A1 &&
-                colorbufferFormat != GL_RGBA8_OES)
+                colorbufferFormat != GL_RGBA8_OES &&
+                colorbufferFormat != GL_RGBA32F)
             {
                 context->recordError(Error(GL_INVALID_OPERATION));
                 return false;
@@ -501,6 +512,13 @@
             context->recordError(Error(GL_INVALID_OPERATION));
             return false;
         }
+
+        if (internalFormatInfo.type == GL_FLOAT &&
+            !context->getExtensions().textureFloat)
+        {
+            context->recordError(Error(GL_INVALID_OPERATION));
+            return false;
+        }
     }
     else
     {