Refactor CopyBufferSubData entry point.

This brings it in line with the new style.

BUG=angleproject:747

Change-Id: Ie4b223d018999be18c3b19fae9cc825a78de09a9
Reviewed-on: https://chromium-review.googlesource.com/405815
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 6930b6e..b090a26 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -2001,4 +2001,56 @@
     return true;
 }
 
+bool ValidateCopyBufferSubData(ValidationContext *context,
+                               GLenum readTarget,
+                               GLenum writeTarget,
+                               GLintptr readOffset,
+                               GLintptr writeOffset,
+                               GLsizeiptr size)
+{
+    if (context->getClientMajorVersion() < 3)
+    {
+        context->handleError(Error(GL_INVALID_OPERATION));
+        return false;
+    }
+
+    if (!ValidBufferTarget(context, readTarget) || !ValidBufferTarget(context, writeTarget))
+    {
+        context->handleError(Error(GL_INVALID_ENUM));
+        return false;
+    }
+
+    Buffer *readBuffer  = context->getGLState().getTargetBuffer(readTarget);
+    Buffer *writeBuffer = context->getGLState().getTargetBuffer(writeTarget);
+
+    if (!readBuffer || !writeBuffer)
+    {
+        context->handleError(Error(GL_INVALID_OPERATION));
+        return false;
+    }
+
+    // Verify that readBuffer and writeBuffer are not currently mapped
+    if (readBuffer->isMapped() || writeBuffer->isMapped())
+    {
+        context->handleError(Error(GL_INVALID_OPERATION));
+        return false;
+    }
+
+    if (readOffset < 0 || writeOffset < 0 || size < 0 ||
+        static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
+        static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
+    {
+        context->handleError(Error(GL_INVALID_VALUE));
+        return false;
+    }
+
+    if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
+    {
+        context->handleError(Error(GL_INVALID_VALUE));
+        return false;
+    }
+
+    return true;
+}
+
 }  // namespace gl