Fix validation for compressed texture functions.
* No validation that the format matched the texture level's format for
SubImage calls.
* WebGL does not allow the base level to be smaller than the block size.
* ANGLE used to allow mips of size 3 when this is disallowed.
* Don't early-exit validation when dimensions are 0, imageSize validation
happens later.
TEST=conformance/extensions/webgl-compressed-texture-s3tc
BUG=angleproject:1998
Change-Id: I05f5a0b5180344d67b036fdecc17edd2256e85ab
Reviewed-on: https://chromium-review.googlesource.com/480442
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index fa85a9e..9070a15 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -204,11 +204,32 @@
return false;
}
- if (!ValidCompressedImageSize(context, actualFormatInfo.internalFormat, xoffset, yoffset,
- width, height))
+ if (isSubImage)
{
- context->handleError(Error(GL_INVALID_OPERATION));
- return false;
+ if (!ValidCompressedSubImageSize(
+ context, actualFormatInfo.internalFormat, xoffset, yoffset, width, height,
+ texture->getWidth(target, level), texture->getHeight(target, level)))
+ {
+ context->handleError(
+ Error(GL_INVALID_OPERATION, "Invalid compressed format dimension."));
+ return false;
+ }
+
+ if (format != actualInternalFormat)
+ {
+ context->handleError(Error(
+ GL_INVALID_OPERATION, "Format must match the internal format of the texture."));
+ return false;
+ }
+ }
+ else
+ {
+ if (!ValidCompressedImageSize(context, actualInternalFormat, level, width, height))
+ {
+ context->handleError(
+ Error(GL_INVALID_OPERATION, "Invalid compressed format dimension."));
+ return false;
+ }
}
if (!actualFormatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
@@ -240,11 +261,6 @@
return false;
}
- if (width == 0 || height == 0 || depth == 0)
- {
- return false;
- }
-
if (xoffset < 0 || yoffset < 0 || zoffset < 0)
{
context->handleError(Error(GL_INVALID_VALUE));
@@ -1831,7 +1847,7 @@
}
return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, 0, 0, 0,
- width, height, depth, 0, GL_NONE, GL_NONE, -1, data);
+ width, height, depth, 0, format, GL_NONE, -1, data);
}
bool ValidateCompressedTexSubImage3DRobustANGLE(Context *context,
GLenum target,