Add a GL_ANGLE_robust_client_memory extension.
This allows specifying data size to all GL functions that provide a pointer to
client memory and a length parameter for all functions in which the driver
writes to client memory.
BUG=angleproject:1354
Change-Id: Ia68be1576b957cb529c87b5e0d1bd638c7dbd371
Reviewed-on: https://chromium-review.googlesource.com/382012
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index d288748..c92ddad 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -285,9 +285,21 @@
} // anonymous namespace
-bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage,
- GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+bool ValidateES2TexImageParameters(Context *context,
+ GLenum target,
+ GLint level,
+ GLenum internalformat,
+ bool isCompressed,
+ bool isSubImage,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLint border,
+ GLenum format,
+ GLenum type,
+ GLsizei imageSize,
+ const GLvoid *pixels)
{
if (!ValidTexture2DDestinationTarget(context, target))
{
@@ -692,6 +704,12 @@
}
}
+ if (!ValidImageDataSize(context, target, width, height, 1, internalformat, type, pixels,
+ imageSize))
+ {
+ return false;
+ }
+
return true;
}
@@ -1962,12 +1980,43 @@
if (context->getClientMajorVersion() < 3)
{
return ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
- 0, 0, width, height, border, format, type, pixels);
+ 0, 0, width, height, border, format, type, -1, pixels);
}
ASSERT(context->getClientMajorVersion() >= 3);
return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0,
- 0, 0, width, height, 1, border, format, type, pixels);
+ 0, 0, width, height, 1, border, format, type, -1,
+ pixels);
+}
+
+bool ValidateTexImage2DRobust(Context *context,
+ GLenum target,
+ GLint level,
+ GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLint border,
+ GLenum format,
+ GLenum type,
+ GLsizei bufSize,
+ const GLvoid *pixels)
+{
+ if (!ValidateRobustEntryPoint(context, bufSize))
+ {
+ return false;
+ }
+
+ if (context->getClientMajorVersion() < 3)
+ {
+ return ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
+ 0, 0, width, height, border, format, type, bufSize,
+ pixels);
+ }
+
+ ASSERT(context->getClientMajorVersion() >= 3);
+ return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0,
+ 0, 0, width, height, 1, border, format, type, bufSize,
+ pixels);
}
bool ValidateTexSubImage2D(Context *context,
@@ -1985,12 +2034,13 @@
if (context->getClientMajorVersion() < 3)
{
return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset,
- yoffset, width, height, 0, format, type, pixels);
+ yoffset, width, height, 0, format, type, -1, pixels);
}
ASSERT(context->getClientMajorVersion() >= 3);
return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset,
- yoffset, 0, width, height, 1, 0, format, type, pixels);
+ yoffset, 0, width, height, 1, 0, format, type, -1,
+ pixels);
}
bool ValidateCompressedTexImage2D(Context *context,
@@ -2006,7 +2056,7 @@
if (context->getClientMajorVersion() < 3)
{
if (!ValidateES2TexImageParameters(context, target, level, internalformat, true, false, 0,
- 0, width, height, border, GL_NONE, GL_NONE, data))
+ 0, width, height, border, GL_NONE, GL_NONE, -1, data))
{
return false;
}
@@ -2015,7 +2065,7 @@
{
ASSERT(context->getClientMajorVersion() >= 3);
if (!ValidateES3TexImage2DParameters(context, target, level, internalformat, true, false, 0,
- 0, 0, width, height, 1, border, GL_NONE, GL_NONE,
+ 0, 0, width, height, 1, border, GL_NONE, GL_NONE, -1,
data))
{
return false;
@@ -2054,7 +2104,7 @@
if (context->getClientMajorVersion() < 3)
{
if (!ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, xoffset,
- yoffset, width, height, 0, GL_NONE, GL_NONE, data))
+ yoffset, width, height, 0, GL_NONE, GL_NONE, -1, data))
{
return false;
}
@@ -2063,7 +2113,7 @@
{
ASSERT(context->getClientMajorVersion() >= 3);
if (!ValidateES3TexImage2DParameters(context, target, level, GL_NONE, true, true, xoffset,
- yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE,
+ yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, -1,
data))
{
return false;