Commit bdc9b2f0 by Geoff Lang

Add validation for GL_RED and GL_RG in glReadPixels.

EXT_texture_rg adds support for these readback formats but validation was not added. BUG=angle:609 Change-Id: Iddd94bb8d8cf3b244a0d8a59cd4445ffa2ae61fe Reviewed-on: https://chromium-review.googlesource.com/195176Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b5b02857
......@@ -847,8 +847,8 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize
if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
return false;
bool validReadFormat = (clientVersion < 3) ? ValidES2ReadFormatType(format, type) :
ValidES3ReadFormatType(currentInternalFormat, format, type);
bool validReadFormat = (clientVersion < 3) ? ValidES2ReadFormatType(context, format, type) :
ValidES3ReadFormatType(context, currentInternalFormat, format, type);
if (!(currentFormat == format && currentType == type) && !validReadFormat)
{
......
......@@ -1044,7 +1044,7 @@ bool ValidateES2FramebufferTextureParameters(gl::Context *context, GLenum target
}
// check for combinations of format and type that are valid for ReadPixels
bool ValidES2ReadFormatType(GLenum format, GLenum type)
bool ValidES2ReadFormatType(gl::Context *context, GLenum format, GLenum type)
{
switch (format)
{
......@@ -1068,6 +1068,21 @@ bool ValidES2ReadFormatType(GLenum format, GLenum type)
return false;
}
break;
case GL_RG_EXT:
case GL_RED_EXT:
if (!context->supportsRGTextures())
{
return false;
}
switch (type)
{
case GL_UNSIGNED_BYTE:
break;
default:
return false;
}
break;
default:
return false;
}
......
......@@ -28,7 +28,7 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize
bool ValidateES2FramebufferTextureParameters(gl::Context *context, GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
bool ValidES2ReadFormatType(GLenum format, GLenum type);
bool ValidES2ReadFormatType(gl::Context *context, GLenum format, GLenum type);
}
......
......@@ -729,7 +729,7 @@ bool ValidateES3FramebufferTextureParameters(gl::Context *context, GLenum target
return true;
}
bool ValidES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type)
bool ValidES3ReadFormatType(gl::Context *context, GLenum internalFormat, GLenum format, GLenum type)
{
switch (format)
{
......@@ -784,6 +784,20 @@ bool ValidES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type)
return false;
}
break;
case GL_RG_EXT:
case GL_RED_EXT:
if (!context->supportsRGTextures())
{
return false;
}
switch (type)
{
case GL_UNSIGNED_BYTE:
break;
default:
return false;
}
break;
default:
return false;
}
......
......@@ -29,7 +29,7 @@ bool ValidateES3FramebufferTextureParameters(gl::Context *context, GLenum target
GLenum textarget, GLuint texture, GLint level, GLint layer,
bool layerCall);
bool ValidES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type);
bool ValidES3ReadFormatType(gl::Context *context, GLenum internalFormat, GLenum format, GLenum type);
bool ValidateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments,
const GLenum* attachments);
......
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