Support compressed textures with unpack buffers.

BUG=angle:792

Change-Id: I32f32422232bd4cb04c8a70005cb51482224bf3e
Reviewed-on: https://chromium-review.googlesource.com/224655
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/validationES3.cpp b/src/libGLESv2/validationES3.cpp
index 251c6ad..4b305db 100644
--- a/src/libGLESv2/validationES3.cpp
+++ b/src/libGLESv2/validationES3.cpp
@@ -542,7 +542,8 @@
             return false;
         }
 
-        size_t copyBytes = widthSize * heightSize * depthSize * pixelBytes;
+        const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedFormat);
+        size_t copyBytes = formatInfo.computeBlockSize(type, width, height);
         size_t offset = reinterpret_cast<size_t>(pixels);
 
         if (!rx::IsUnsignedAdditionSafe(offset, copyBytes) ||
@@ -555,12 +556,15 @@
 
         // ...data is not evenly divisible into the number of bytes needed to store in memory a datum
         // indicated by type.
-        size_t dataBytesPerPixel = static_cast<size_t>(gl::GetTypeInfo(type).bytes);
-
-        if ((offset % dataBytesPerPixel) != 0)
+        if (!isCompressed)
         {
-            context->recordError(Error(GL_INVALID_OPERATION));
-            return false;
+            size_t dataBytesPerPixel = static_cast<size_t>(gl::GetTypeInfo(type).bytes);
+
+            if ((offset % dataBytesPerPixel) != 0)
+            {
+                context->recordError(Error(GL_INVALID_OPERATION));
+                return false;
+            }
         }
 
         // ...the buffer object's data store is currently mapped.