Commit 62fce5b1 by Geoff Lang Committed by Commit Bot

Implement robust ReadPixels entry points.

BUG=angleproject:1354 Change-Id: I70738d2f00e283ddc52b1545f8efda9022110487 Reviewed-on: https://chromium-review.googlesource.com/391090 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d258ca04
...@@ -107,6 +107,16 @@ bool ValidateReadPixels(ValidationContext *context, ...@@ -107,6 +107,16 @@ bool ValidateReadPixels(ValidationContext *context,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLvoid *pixels); GLvoid *pixels);
bool ValidateReadPixelsRobustANGLE(ValidationContext *context,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
GLsizei bufSize,
GLsizei *length,
GLvoid *pixels);
bool ValidateReadnPixelsEXT(Context *context, bool ValidateReadnPixelsEXT(Context *context,
GLint x, GLint x,
GLint y, GLint y,
...@@ -116,6 +126,16 @@ bool ValidateReadnPixelsEXT(Context *context, ...@@ -116,6 +126,16 @@ bool ValidateReadnPixelsEXT(Context *context,
GLenum type, GLenum type,
GLsizei bufSize, GLsizei bufSize,
GLvoid *pixels); GLvoid *pixels);
bool ValidateReadnPixelsRobustANGLE(ValidationContext *context,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
GLsizei bufSize,
GLsizei *length,
GLvoid *data);
bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n); bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n);
bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n); bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n);
......
...@@ -2291,7 +2291,21 @@ ANGLE_EXPORT void GL_APIENTRY ReadPixelsRobustANGLE(GLint x, ...@@ -2291,7 +2291,21 @@ ANGLE_EXPORT void GL_APIENTRY ReadPixelsRobustANGLE(GLint x,
"GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufsize = %d, GLsizei* length = " "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufsize = %d, GLsizei* length = "
"0x%0.8p, GLvoid* pixels = 0x%0.8p)", "0x%0.8p, GLvoid* pixels = 0x%0.8p)",
x, y, width, height, format, type, bufSize, length, pixels); x, y, width, height, format, type, bufSize, length, pixels);
UNIMPLEMENTED();
Context *context = GetValidGlobalContext();
if (context)
{
GLsizei writeLength = 0;
if (!ValidateReadPixelsRobustANGLE(context, x, y, width, height, format, type, bufSize,
&writeLength, pixels))
{
return;
}
context->readPixels(x, y, width, height, format, type, pixels);
SetRobustLengthParam(length, writeLength);
}
} }
ANGLE_EXPORT void GL_APIENTRY TexImage2DRobustANGLE(GLenum target, ANGLE_EXPORT void GL_APIENTRY TexImage2DRobustANGLE(GLenum target,
...@@ -2695,7 +2709,21 @@ ANGLE_EXPORT void GL_APIENTRY ReadnPixelsRobustANGLE(GLint x, ...@@ -2695,7 +2709,21 @@ ANGLE_EXPORT void GL_APIENTRY ReadnPixelsRobustANGLE(GLint x,
"GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufsize = %d, GLsizei* length = " "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufsize = %d, GLsizei* length = "
"0x%0.8p, GLvoid *data = 0x%0.8p)", "0x%0.8p, GLvoid *data = 0x%0.8p)",
x, y, width, height, format, type, bufSize, length, data); x, y, width, height, format, type, bufSize, length, data);
UNIMPLEMENTED();
Context *context = GetValidGlobalContext();
if (context)
{
GLsizei writeLength = 0;
if (!ValidateReadnPixelsRobustANGLE(context, x, y, width, height, format, type, bufSize,
&writeLength, data))
{
return;
}
context->readPixels(x, y, width, height, format, type, data);
SetRobustLengthParam(length, writeLength);
}
} }
ANGLE_EXPORT void GL_APIENTRY GetnUniformfvRobustANGLE(GLuint program, ANGLE_EXPORT void GL_APIENTRY GetnUniformfvRobustANGLE(GLuint program,
......
...@@ -334,6 +334,39 @@ TEST_P(RobustClientMemoryTest, TexImage2D) ...@@ -334,6 +334,39 @@ TEST_P(RobustClientMemoryTest, TexImage2D)
} }
} }
// Test basic usage and validation of glReadPixelsRobustANGLE
TEST_P(RobustClientMemoryTest, ReadPixels)
{
if (!extensionsPresent())
{
return;
}
GLsizei dataDimension = 16;
std::vector<GLubyte> rgbaData(dataDimension * dataDimension * 4);
// Test the regular case
GLsizei length = 0;
glReadPixelsRobustANGLE(0, 0, dataDimension, dataDimension, GL_RGBA, GL_UNSIGNED_BYTE,
static_cast<GLsizei>(rgbaData.size()), &length, rgbaData.data());
EXPECT_GL_NO_ERROR();
EXPECT_EQ(static_cast<GLsizei>(rgbaData.size()), length);
// Test with a data size that is too small
glReadPixelsRobustANGLE(0, 0, dataDimension, dataDimension, GL_RGBA, GL_UNSIGNED_BYTE,
static_cast<GLsizei>(rgbaData.size()) - 1, &length, rgbaData.data());
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
if (getClientMajorVersion() >= 3)
{
// Set a pack parameter that would cause the driver to write past the end of the buffer
glPixelStorei(GL_PACK_ROW_LENGTH, dataDimension + 1);
glReadPixelsRobustANGLE(0, 0, dataDimension, dataDimension, GL_RGBA, GL_UNSIGNED_BYTE,
static_cast<GLsizei>(rgbaData.size()), &length, rgbaData.data());
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
ANGLE_INSTANTIATE_TEST(RobustClientMemoryTest, ANGLE_INSTANTIATE_TEST(RobustClientMemoryTest,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment