Commit c51642b4 by Geoff Lang Committed by Commit Bot

Validate level exists for TexSubImage calls.

Before validating the texture format, verify that the texture level already exists in glTexSubImage calls. BUG=602737 Change-Id: I0d83c7d43c7b358abdb59583dc83265df70c13b5 Reviewed-on: https://chromium-review.googlesource.com/411361 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 399d1a17
......@@ -368,10 +368,16 @@ bool ValidateES2TexImageParameters(Context *context,
if (isSubImage)
{
GLenum textureFormat = texture->getFormat(target, level).asSized();
if (textureFormat == GL_NONE)
{
context->handleError(Error(GL_INVALID_OPERATION, "Texture level does not exist."));
return false;
}
if (format != GL_NONE)
{
if (gl::GetSizedInternalFormat(format, type) !=
texture->getFormat(target, level).asSized())
if (gl::GetSizedInternalFormat(format, type) != textureFormat)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
......
......@@ -168,6 +168,12 @@ bool ValidateES3TexImageParametersBase(Context *context,
// Validate texture formats
GLenum actualInternalFormat =
isSubImage ? texture->getFormat(target, level).asSized() : internalformat;
if (isSubImage && actualInternalFormat == GL_NONE)
{
context->handleError(Error(GL_INVALID_OPERATION, "Texture level does not exist."));
return false;
}
const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(actualInternalFormat);
if (isCompressed)
{
......
......@@ -1194,6 +1194,16 @@ TEST_P(Texture2DTest, NegativeAPISubImage)
const GLubyte *pixels[20] = { 0 };
glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
EXPECT_GL_ERROR(GL_INVALID_VALUE);
if (extensionEnabled("GL_EXT_texture_storage"))
{
// Create a 1-level immutable texture.
glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2);
// Try calling sub image on the second level.
glTexSubImage2D(GL_TEXTURE_2D, 1, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
}
// Test that querying GL_TEXTURE_BINDING* doesn't cause an unexpected error.
......
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