Commit 86af3d27 by Jamie Madill

ES3: Fix assertion failure in validation edge case.

Passing a 2D texture type to a 3D texture function could result in an explosion. BUG=angleproject:1079 TEST=dEQP-GLES3.functional.negative_api.texture.compressedteximage3d Change-Id: Ibfcc4bdb334270f8fa27ebed6bcc3911986e7c7c Reviewed-on: https://chromium-review.googlesource.com/286852Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 1ca7467f
...@@ -1249,4 +1249,47 @@ bool ValidateReadBuffer(Context *context, GLenum src) ...@@ -1249,4 +1249,47 @@ bool ValidateReadBuffer(Context *context, GLenum src)
return true; return true;
} }
bool ValidateCompressedTexImage3D(Context *context,
GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLsizei imageSize,
const GLvoid *data)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
if (imageSize < 0 ||
static_cast<GLuint>(imageSize) !=
formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{
context->recordError(Error(GL_INVALID_VALUE));
return false;
}
// 3D texture target validation
if (target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY)
{
context->recordError(
Error(GL_INVALID_ENUM, "Must specify a valid 3D texture destination target"));
return false;
}
// validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false, 0, 0, 0,
width, height, depth, border, GL_NONE, GL_NONE, data))
{
return false;
}
return true;
}
} }
...@@ -44,6 +44,16 @@ bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLu ...@@ -44,6 +44,16 @@ bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLu
bool ValidateReadBuffer(Context *context, GLenum mode); bool ValidateReadBuffer(Context *context, GLenum mode);
bool ValidateCompressedTexImage3D(Context *context,
GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLsizei imageSize,
const GLvoid *data);
} }
#endif // LIBANGLE_VALIDATION_ES3_H_ #endif // LIBANGLE_VALIDATION_ES3_H_
...@@ -206,22 +206,8 @@ void GL_APIENTRY CompressedTexImage3D(GLenum target, GLint level, GLenum interna ...@@ -206,22 +206,8 @@ void GL_APIENTRY CompressedTexImage3D(GLenum target, GLint level, GLenum interna
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!gl::ValidateCompressedTexImage3D(context, target, level, internalformat, width, height,
{ depth, border, imageSize, data))
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
// validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
{ {
return; return;
} }
......
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